Created
January 12, 2022 20:32
-
-
Save driazati/8ec79ab7737af68ff8cd07ea91dfcb71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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