-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_stats.py
More file actions
55 lines (45 loc) · 1.36 KB
/
Copy pathbuild_stats.py
File metadata and controls
55 lines (45 loc) · 1.36 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
import datetime
from dataclasses import dataclass
from collections import defaultdict
import json
from pathlib import Path
@dataclass
class BuildStepTiming:
name: str
date: datetime.datetime
delta: float
def find_and_load_logs(path="logs"):
out = []
for f in sorted(Path("logs").glob("*.json"), reverse=True):
with open(f) as fin:
out.append(json.load(fin))
return out
def package_build_times(logs, skip_pip=True):
out = defaultdict(list)
for log in logs:
for step in log["build_steps"]:
if "packages" in step and skip_pip:
continue
if step["returncode"] != 0:
continue
name = step["name"]
out[name].append(
BuildStepTiming(
name,
datetime.datetime.fromtimestamp(step["start_time"]),
delta=step["stop_time"] - step["start_time"],
)
)
return dict(out)
def plot_trace(ax, times, package, **kwargs):
return ax.plot(
*zip(*[(_.date, _.delta) for _ in times[package]]),
"o",
**{"label": package, **kwargs},
)
def compare_build_times(ax, times, packages, **kwargs):
ax.set_ylabel("build time [s]")
ax.set_xlabel("date")
for p in packages:
plot_trace(ax, times, p, **kwargs)
ax.legend()