Skip to content

Instantly share code, notes, and snippets.

@driazati
Created January 12, 2022 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save driazati/8ec79ab7737af68ff8cd07ea91dfcb71 to your computer and use it in GitHub Desktop.
Save driazati/8ec79ab7737af68ff8cd07ea91dfcb71 to your computer and use it in GitHub Desktop.
# 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