-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_cf_win.py
88 lines (75 loc) · 2.97 KB
/
test_cf_win.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import subprocess, sys, os
# Linux:
#pattern_loc = '/media/robertubu/Twardziel1/Politechnika/#doktorat/Multiple/patterns' # each folder should have name with suffix .r1000 where 1000 is number of patterns
#set_loc = '/media/robertubu/Twardziel1/Politechnika/#doktorat/Multiple/sets'
#output_loc = '/media/robertubu/Twardziel1/Politechnika/#doktorat/Multiple/out'
#alg_loc = './'
# Windows
pattern_loc = 'Y:/Multiple/patterns' # each folder should have name with suffix r1000 where 1000 is number of patterns
set_loc = 'Y:/Multiple/sets'
output_loc = 'Y:/Single/out'
alg_loc = 'Y:/Single/Single/source'
args_num = len(sys.argv) - 1
curr_path = os.getcwd()
arg_offset = 0
# Error
if args_num < 1:
print >> sys.stderr, "Error not enought parameters. See --help."
exit()
if sys.argv[1]=='--help':
print ('Pattern matching tester help.')
print ('')
print ('Syntax:')
print ('test [--help] algorithm[.exe] test_set r m u k')
print ('')
print ('--help Shows the help')
print ('algorithm Algorithm(eg. cf,fso)')
print ('test_set Test set(eg. english.100MB)')
print ('r Pattern number(eg. 1000)')
print ('m Pattern length(eg. 8)')
print ('')
print ('Example:')
print ('test.py cf2_skip english.200MB 10 8,16,32,64')
print ('')
exit()
# Error
if args_num < 4:
print ("Error not enought parameters. See --help.")
exit()
# algorithm
algs = sys.argv[1] # algorithms
# arguments:
set_args = sys.argv[2] # test text sets
r_args = sys.argv[3] #
m_args = sys.argv[4] # pattern length
set_args_list = set_args.split(',')
a_args_list = algs.split(',')
r_args_list = r_args.split(',')
m_args_list = m_args.split(',')
print ('Starting calculation for following parameters')
print ('Sets : ' + set_args)
print ('M : ' + m_args)
print ('A\t' + 'S\t' + 'R\t' + 'M\t' + 'Sig\t' + 'Q\t' + 'k\t' + 'Run\t' + 'Ver\t' + 'Matches')
for a in a_args_list:
for s in set_args_list:
for r in r_args_list:
for m in m_args_list:
proc_filename = alg_loc + '/' + a
pattern_filename = pattern_loc + '.r' + r + '/patterns.' + s + '.' + m + '.bin'
set_filename = set_loc + '/' + s
if not os.path.isfile(proc_filename):
print ("Error: The prog file not found ( "+proc_filename+")")
exit()
if not os.path.isfile(pattern_filename):
print ("Error: The pattern file not found ( "+pattern_filename+")")
exit()
if not os.path.isfile(set_filename):
print ("Error: The set file not found ( "+set_filename+")")
exit()
#print proc_filename, pattern_filename, m, set_filename, u, k, q
proc = subprocess.Popen([proc_filename, pattern_filename, m, set_filename], stdout=subprocess.PIPE)
output = proc.stdout.read().decode('ascii')
output = a + '\t' + s + '\t' + str(r) + '\t' + str(m) + '\t' + output;
sys.stdout.write(output)
sys.stdout.flush()
# subprocess.call(['Solution\\Release\\Test.exe'])