Instantly share code, notes, and snippets.

Embed
What would you like to do?
import time
import subprocess
times = {}
def fmt(s):
return f'{s:.2f}s'
def test(workers):
cmd = f'yarn run test --maxWorkers={workers}'
print(cmd)
if workers not in times:
times[workers] = []
t0 = time.time()
output = subprocess.run(cmd, shell=True, check=True)
t1 = time.time()
assert not output.returncode
times[workers].append(t1 - t0)
import random
workers = list(range(1, 9)) * 4
random.shuffle(workers)
for worker in workers:
test(worker)
import statistics
for workers in sorted(times):
these = times[workers]
print("WORKERS:", workers)
print("BEST :", fmt(min(these)))
print("MEDIAN :", fmt(statistics.median(these)))
print()
print("SORTED BY BEST TIME:")
bests = []
for workers in times:
best = min(times[workers])
bests.append((best, workers))
bests.sort()
for seconds, workers in bests:
print(workers, fmt(seconds))
@peterbe

This comment has been minimized.

Show comment
Hide comment
@peterbe

peterbe Oct 8, 2018

Run it like this:

CI=true python36 bestjest.py

...and wait.

My output became:

3 8.47s
4 8.59s
6 9.12s
5 9.18s
2 9.51s
7 10.14s
8 10.59s
1 13.80s
Owner

peterbe commented Oct 8, 2018

Run it like this:

CI=true python36 bestjest.py

...and wait.

My output became:

3 8.47s
4 8.59s
6 9.12s
5 9.18s
2 9.51s
7 10.14s
8 10.59s
1 13.80s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment