-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathprocess.py
More file actions
executable file
·47 lines (42 loc) · 1.42 KB
/
process.py
File metadata and controls
executable file
·47 lines (42 loc) · 1.42 KB
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
#!/usr/bin/env python3
import os
import json
from itertools import groupby
from pathlib import Path
with Path('results.json').open() as f:
results = json.load(f)
compare = os.getenv('COMPARE', 'aiohttp').lower()
assert compare in ('python', 'aiohttp')
not_compared = 'python' if compare == 'aiohttp' else 'aiohttp'
grouping = not_compared, 'url', 'db', 'queries', 'concurrency'
sort_on = grouping + (compare,)
results.sort(key=lambda v: [v[g] for g in sort_on])
i = 0
head = None
url_previous = None
for k, g in groupby(results, lambda v: [v[g] for g in grouping]):
not_compared_version, url, db, queries, concurrency = k
if url_previous and url_previous != url:
print()
url_previous = url
if i == 0:
head = f'{"URL":>18} {not_compared:>8} {"DB":>8} {"queries":>8} {"Conc":>8} '
line = f'{url:>18} {not_compared_version:>8} {db:>8} {queries:>8} {concurrency:>8} '
ref = None
for j, data in enumerate(g):
s = f'{data["request_rate"]:0,.0f}'
if j == 0:
if i == 0:
head += f'{data[compare]:>10} '
ref = data["request_rate"]
line += f'{s:>10} '
else:
if i == 0:
head += f'{data[compare]:>15} '
improvement = (data['request_rate'] - ref) / ref * 100
s += f' |{improvement:3.0f}%'
line += f'{s:>15} '
if i == 0:
print(head)
print(line)
i += 1