Skip to content

Commit 9297743

Browse files
committed
test(benchmark): more error checking before running long tests
1 parent 2cf1981 commit 9297743

File tree

1 file changed

+46
-144
lines changed

1 file changed

+46
-144
lines changed

lab/benchmark.py

+46-144
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import shutil
88
import statistics
99
import subprocess
10+
import sys
1011
import time
1112
from pathlib import Path
1213

@@ -443,147 +444,48 @@ def as_table_row(vals):
443444

444445
PERF_DIR = Path("/tmp/covperf")
445446

446-
447-
print(f"Removing and re-making {PERF_DIR}")
448-
rmrf(PERF_DIR)
449-
450-
with change_dir(PERF_DIR):
451-
452-
if 1:
453-
exp = Experiment(
454-
py_versions=[
455-
Python(3, 11),
456-
AdHocPython("/usr/local/cpython", "gh93818"),
457-
],
458-
cov_versions=[
459-
Coverage("6.4.1", "coverage==6.4.1"),
460-
],
461-
projects=[
462-
AdHocProject("/src/bugs/bug1339/bug1339.py"),
463-
SlipcoverBenchmark("bm_sudoku.py"),
464-
SlipcoverBenchmark("bm_spectral_norm.py"),
465-
],
466-
)
467-
exp.run(num_runs=3)
468-
exp.show_results(
469-
rows=["cov", "proj"],
470-
column="pyver",
471-
ratios=[
472-
("93818 vs 3.11", "gh93818", "python3.11"),
473-
],
474-
)
475-
if 0:
476-
exp = Experiment(
477-
py_versions=[
478-
Python(3, 11),
479-
],
480-
cov_versions=[
481-
CoverageCommit("0b749007"),
482-
CoverageSource("~/coverage/trunk"),
483-
],
484-
projects=[
485-
AdHocProject("/src/bugs/bug1339/bug1339.py"),
486-
SlipcoverBenchmark("bm_sudoku.py"),
487-
SlipcoverBenchmark("bm_spectral_norm.py"),
488-
],
489-
)
490-
exp.run(num_runs=31)
491-
exp.show_results(
492-
rows=["pyver", "proj"],
493-
column="cov",
494-
ratios=[
495-
("compare", "source", "0b749007"),
496-
],
497-
)
498-
if 0:
499-
exp = Experiment(
500-
py_versions=[
501-
Python(3, 11),
502-
],
503-
cov_versions=[
504-
Coverage("6.4.1", "coverage==6.4.1"),
505-
CoveragePR(1394),
506-
],
507-
projects=[
508-
AdHocProject("/src/bugs/bug1339/bug1339.py"),
509-
SlipcoverBenchmark("bm_sudoku.py"),
510-
SlipcoverBenchmark("bm_spectral_norm.py"),
511-
],
512-
)
513-
exp.run(num_runs=5)
514-
exp.show_results(
515-
rows=["pyver", "proj"],
516-
column="cov",
517-
ratios=[
518-
("#1394 vs 6.4.1", "#1394", "6.4.1"),
519-
],
520-
)
521-
if 0:
522-
exp = Experiment(
523-
py_versions=[
524-
Python(3, 10),
525-
Python(3, 11),
526-
#AdHocPython("/usr/local/cpython", "gh93493"),
527-
],
528-
cov_versions=[
529-
Coverage("none"),
530-
Coverage("6.4.1", "coverage==6.4.1"),
531-
# Coverage(
532-
# "tip timid",
533-
# "git+https://github.com/nedbat/coveragepy.git@master",
534-
# "timid=True",
535-
# ),
536-
],
537-
projects=[
538-
# ProjectPytestHtml(),
539-
#ProjectAttrs(),
540-
AdHocProject("/src/bugs/bug1339/bug1339.py"),
541-
SlipcoverBenchmark("bm_sudoku.py"),
542-
SlipcoverBenchmark("bm_spectral_norm.py"),
543-
],
544-
)
545-
exp.run(num_runs=3)
546-
exp.show_results(
547-
rows=["cov", "proj"],
548-
column="pyver",
549-
ratios=[
550-
("3.11 vs 3.10", "python3.11", "python3.10"),
551-
#("fix vs 3.10", "gh93493", "python3.10"),
552-
],
553-
)
554-
555-
if 0:
556-
exp = Experiment(
557-
py_versions=[
558-
PyPy(3, 9),
559-
],
560-
cov_versions=[
561-
Coverage("none", None, None),
562-
Coverage("6.4", "coverage==6.4", ""),
563-
Coverage(
564-
"PR 1381",
565-
"git+https://github.com/cfbolz/coveragepy.git@f_trace_lines",
566-
"",
567-
),
568-
],
569-
projects=[
570-
ProjectPytestHtml(),
571-
],
572-
)
573-
exp.run(num_runs=3)
574-
575-
if 0:
576-
exp = Experiment(
577-
py_versions=[
578-
PyPy(3, 9),
579-
],
580-
cov_versions=[
581-
Coverage("none", None, None),
582-
Coverage("6.4", "coverage", ""),
583-
Coverage("tip", "git+https://github.com/nedbat/coveragepy.git@master", ""),
584-
],
585-
projects=[
586-
AdHocProject("/src/bugs/bug1339/bug1339.py"),
587-
],
588-
)
589-
exp.run(num_runs=7)
447+
def run_experiment(
448+
py_versions: List[PyVersion], cov_versions: List[Coverage], projects: List[ProjectToTest],
449+
rows: List[str], column: str, ratios: Iterable[Tuple[str, str, str]] = (),
450+
):
451+
slugs = [v.slug for v in py_versions + cov_versions + projects]
452+
if len(set(slugs)) != len(slugs):
453+
raise Exception(f"Slugs must be unique: {slugs}")
454+
if any(" " in slug for slug in slugs):
455+
raise Exception(f"No spaces in slugs please: {slugs}")
456+
ratio_slugs = [rslug for ratio in ratios for rslug in ratio[1:]]
457+
if any(rslug not in slugs for rslug in ratio_slugs):
458+
raise Exception(f"Ratio slug doesn't match a slug: {ratio_slugs}, {slugs}")
459+
460+
print(f"Removing and re-making {PERF_DIR}")
461+
rmrf(PERF_DIR)
462+
463+
with change_dir(PERF_DIR):
464+
exp = Experiment(py_versions=py_versions, cov_versions=cov_versions, projects=projects)
465+
exp.run(num_runs=int(sys.argv[1]))
466+
exp.show_results(rows=rows, column=column, ratios=ratios)
467+
468+
469+
if 1:
470+
run_experiment(
471+
py_versions=[
472+
#Python(3, 11),
473+
AdHocPython("/usr/local/cpython/v3.10.5", "v3.10.5"),
474+
AdHocPython("/usr/local/cpython/v3.11.0b3", "v3.11.0b3"),
475+
AdHocPython("/usr/local/cpython/94231", "94231"),
476+
],
477+
cov_versions=[
478+
Coverage("6.4.1", "coverage==6.4.1"),
479+
],
480+
projects=[
481+
AdHocProject("/src/bugs/bug1339/bug1339.py"),
482+
SlipcoverBenchmark("bm_sudoku.py"),
483+
SlipcoverBenchmark("bm_spectral_norm.py"),
484+
],
485+
rows=["cov", "proj"],
486+
column="pyver",
487+
ratios=[
488+
("3.11b3 vs 3.10", "v3.11.0b3", "v3.10.5"),
489+
("94231 vs 3.10", "94231", "v3.10.5"),
490+
],
491+
)

0 commit comments

Comments
 (0)