-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.py
executable file
·41 lines (31 loc) · 1 KB
/
stats.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
#!/usr/bin/python
import sys, getopt
import numpy
RESULT_FORMAT="{:8.2f} {:8.2f} {:8.2f} {:8.2f} {:8.2f} {:8.2f}"
def main(argv):
inputfile = ''
outputfile = ''
try:
opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
except getopt.GetoptError:
print 'test.py -i <inputfile> -o <outputfile>'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'test.py -i <inputfile> -o <outputfile>'
sys.exit()
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-o", "--ofile"):
outputfile = arg
with open(inputfile) as fp:
Lines = fp.readlines()
del Lines[0]
res = [line.rstrip() for line in Lines]
microres = [float(line)*1000000 for line in res]
a=numpy.array(microres)
print RESULT_FORMAT.format(numpy.mean(a), numpy.std(a), numpy.percentile(a,
90), numpy.percentile(a,95), numpy.percentile(a,99),
numpy.percentile(a,99.9))
if __name__ == "__main__":
main(sys.argv[1:])