Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# download CI logs to a folder with this file and run
# for i in (seq 10 10 100) (base) [ 12:30:34 ]
# python slow_test_times.py $i
# end
import subprocess
import sys
from pathlib import Path
p = Path(".").glob("*.ai")
SLOW_THRESHOLD = float(sys.argv[1])
def log(x):
print(f"[cutoff={SLOW_THRESHOLD}s] {x}")
total_savings_s = 0
total_skipped = 0
for file in p:
out = subprocess.run(
f"cat '{file}' | grep 'call ' | sed 's/s call.*//g' | sort -V ",
shell=True,
stdout=subprocess.PIPE,
encoding="utf-8",
).stdout
times = [float(x) for x in out.split("\n") if x != ""]
times = [x for x in times if x > SLOW_THRESHOLD]
total_savings_s += sum(times)
total_skipped += len(times)
log(
f"@slow in {file} saves {round(sum(times) / 60, 2)}m by moving {len(times)} tests to main-only"
)
log(f"Total savings (m): {round(total_savings_s / 60, 2)}m by skipping {total_skipped} tests")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment