summaryrefslogtreecommitdiffstats
path: root/summarize.py
diff options
context:
space:
mode:
Diffstat (limited to 'summarize.py')
-rwxr-xr-xsummarize.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/summarize.py b/summarize.py
new file mode 100755
index 0000000..2183c41
--- /dev/null
+++ b/summarize.py
@@ -0,0 +1,78 @@
1#!/usr/bin/python3
2import sys
3
4f = sys.argv[1]
5if len(sys.argv) < 2:
6 print("Usage "+sys.argv[0]+" <filename> --inf-precision")
7res = {}
8mem_res = {}
9memw_res = {}
10samples = {}
11max_res = {}
12
13with open(f) as fp:
14 for line in fp:
15 s = line.split()
16 if s[0] not in res:
17# print(s[0])
18 res[s[0]] = list([int(s[5])])#)int(s[5])
19 mem_res[s[0]] = int(s[8])
20 memw_res[s[0]] = int(s[9])
21 samples[s[0]] = int(s[4])
22 max_res[s[0]] = int(s[5])
23 else:
24 res[s[0]].append(int(s[5]))
25 mem_res[s[0]] += int(s[8])
26 memw_res[s[0]] += int(s[9])
27 max_res[s[0]] = max(int(s[5]), max_res[s[0]])
28## {{{ http://code.activestate.com/recipes/511478/ (r1)
29import math
30import functools
31
32def percentile(N, percent, key=lambda x:x):
33 """
34 Find the percentile of a list of values.
35
36 @parameter N - is a list of values. Note N MUST BE already sorted.
37 @parameter percent - a float value from 0.0 to 1.0.
38 @parameter key - optional key function to compute value from each element of N.
39
40 @return - the percentile of the values
41 """
42 if not N:
43 return None
44 k = (len(N)-1) * percent
45 f = math.floor(k)
46 c = math.ceil(k)
47 if f == c:
48 return key(N[int(k)])
49 d0 = key(N[int(f)]) * (c-k)
50 d1 = key(N[int(c)]) * (k-f)
51 return d0+d1
52## end of http://code.activestate.com/recipes/511478/ }}}
53def memstring(memr, memw, samples):
54 if memr or memw:
55 return "\t{:>12.f}\t{:>12.f}".format(memr/samples, memw/samples)
56 else:
57 return ""
58avg_max = 0
59avg_99th = 0
60avg_avg = 0
61# Only include memory info in the header if relevant
62if mem_res[s[0]] == 0:
63 print("Name\t\tAverage\t\tMax\t\t99th %")
64else:
65 print("Name\t\tAverage\t\tMax\t\t99th %\t\tAvg Mem Read\tAvg Mem Write\t")
66for r in sorted(res.keys()):
67# print(r + "\t\t" + str(res[r]/samples[r]) + "\t\t" + str(max_res[r]))
68 avg_avg += sum(res[r])/len(res[r])
69 avg_max += max(res[r])
70 avg_99th += percentile(sorted(res[r]), 0.99)
71 if len(sys.argv) > 2 and sys.argv[2] == "--inf-precision":
72 print("{:12}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}".format(r, sum(res[r])/len(res[r]), max(res[r]), percentile(sorted(res[r]), 0.99)) + memstring(mem_res[r], memw_res[r], samples[r]))
73 else:
74 print("{:12.12}\t{:>12.0f}\t{:>12.0f}\t{:>12.0f}".format(r, sum(res[r])/len(res[r]), max(res[r]), percentile(sorted(res[r]), 0.99)) + memstring(mem_res[r], memw_res[r], samples[r]))
75
76print("Average average:", avg_avg/len(res.keys()))
77print("Average max:", avg_max/len(res.keys()))
78print("Average 99th:", avg_99th/len(res.keys()))