-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsummary.py
46 lines (36 loc) · 1 KB
/
summary.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
import json
from collections import Counter, defaultdict
from pprint import pprint
import sys
def stream(path):
with open(path) as f:
for x in f.readlines():
yield json.loads(x)
def summary(report):
s = stream(report)
meta = next(s)
pprint(meta)
geomeanCount = 0
geomean = 1
worstSpeed = (0.0, None)
statuscodes = Counter()
tags = Counter()
for el in s:
statuscodes.update([el["statuscode"]])
if "tags" in el:
tags[el["statuscode"]].update(el["tags"])
geomean *= el["seconds"]
if worstSpeed[0] <= el["seconds"]:
worstSpeed = (el["seconds"], el["sample"])
geomeanCount += 1
print("average build time:")
print(geomean ** (1/geomeanCount))
print("worst build time:")
print(worstSpeed)
print("status codes:")
print(statuscodes)
print("tags by statuscode:")
for k, v in tags.items():
print(" ", k, ":", v)
if __name__ == "__main__":
summary(sys.argv[1])