-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaging.py
More file actions
executable file
·59 lines (47 loc) · 2.16 KB
/
Copy pathaging.py
File metadata and controls
executable file
·59 lines (47 loc) · 2.16 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
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
"""Quantify session-aging tax: same suite measured in one long browser session versus
a fresh browser per category.
./aging.py --aged one-session.json --fresh split.json
Tests whose aged time far exceeds their fresh time were penalized by state accumulated
from everything that ran before them (leaked documents, heap growth, ...). The aged run
is the realistic one: real benchmarks and real browsing are long sessions.
"""
import argparse
import json
def load_times(path):
with open(path) as f:
data = json.load(f)
times = {}
for benchmark, tests in data.items():
for key, value in tests.items():
if key == "_total" or "time" not in value:
continue
times[f"{benchmark}/{key}"] = value["time"]["mean"]
return times
def main():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--aged", required=True, help="Result JSON from a single long session")
parser.add_argument("--fresh", required=True, help="Result JSON from --split-suites (fresh browser per category)")
parser.add_argument("--min-tax", type=float, default=1.5, help="Only show tests at or above this aged/fresh ratio")
args = parser.parse_args()
aged = load_times(args.aged)
fresh = load_times(args.fresh)
rows = []
total_aged = total_fresh = 0.0
for key in aged:
if key not in fresh or fresh[key] == 0:
continue
total_aged += aged[key]
total_fresh += fresh[key]
rows.append((key, aged[key], fresh[key], aged[key] / fresh[key]))
rows.sort(key=lambda row: -row[3])
width = max((len(key) for key, *_ in rows), default=20)
print(f"{'Test':{width}s} {'Aged':>10s} {'Fresh':>10s} {'Tax':>7s}")
for key, aged_time, fresh_time, tax in rows:
if tax < args.min_tax:
break
print(f"{key:{width}s} {aged_time * 1000:9.2f}m {fresh_time * 1000:9.2f}m {tax:6.1f}x")
if total_fresh:
print(f"\n{'TOTAL':{width}s} {total_aged * 1000:9.1f}m {total_fresh * 1000:9.1f}m {total_aged / total_fresh:6.1f}x")
if __name__ == "__main__":
main()