-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquicktest.py
executable file
·81 lines (64 loc) · 2.34 KB
/
quicktest.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
#!/usr/bin/env python
import argparse
import gc
import sys
import os
usage_info = '''usage: %s <options>
at a minimum, specify --infile <file.out>''' % sys.argv[0]
if len(sys.argv) <= 1:
print usage_info
exit()
parser = argparse.ArgumentParser(description=usage_info, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('--infile',
type=str,
nargs='+',
required=True,
dest='infile',
help='input file (required)')
parser.add_argument('--pend',
action='store_true',
dest='pend',
help='report pend times')
parser.add_argument('--ssusp',
action='store_true',
dest='ssusp',
help='report ssusp times')
parser.add_argument('--percent',
action='store_true',
dest='percent',
help='report as percentage of runtime')
args = parser.parse_args()
l_infiles = args.infile
for infile in l_infiles:
if infile and not os.path.isfile(infile):
print "%s isn't a file!" % infile
exit(1)
def fucking_magic(datafile):
'''Create a list from the input file, filterd based on arguments'''
gc.disable()
input_fn = datafile
input_fh = open(input_fn, "r")
l_answers = []
l_percent = []
for row in input_fh:
line = row.split(None)
pend_t = int(line[10])
run_t = int(line[12])
ssusp_t = int(line[14])
if run_t > 0 and args.pend:
l_answers.append(pend_t)
l_percent.append(float(pend_t)/(pend_t+run_t)*100)
elif run_t > 0 and args.ssusp:
l_answers.append(ssusp_t)
l_percent.append(float(ssusp_t)/(ssusp_t+run_t)*100)
gc.enable()
return l_answers, l_percent
print "name,min,max,avg"
for datafile in l_infiles:
fucking_answers = fucking_magic(datafile)[0]
fucking_percents = fucking_magic(datafile)[1]
dataname = datafile.replace('.out','')
if not args.percent:
print "%s,%s,%s,%s" % (dataname,min(fucking_answers),max(fucking_answers),sum(fucking_answers)/len(fucking_answers))
elif args.percent:
print "%s,%0.2f,%0.2f,%0.2f" % (dataname,min(fucking_percents),max(fucking_percents),sum(fucking_percents)/len(fucking_percents))