diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2022-06-03 13:44:13 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2022-06-03 13:45:26 -0400 |
commit | 50e8d938315dacce9c5d3de1a25c771cdfe943ec (patch) | |
tree | 669e9bed2dd473c69aec55c9b01307227b657cfe /lab/benchmark.py | |
parent | 2d7014cb861b00ac32c2ae8b5d3401be494b256d (diff) | |
download | python-coveragepy-git-50e8d938315dacce9c5d3de1a25c771cdfe943ec.tar.gz |
test: more benchmarking
```
Median for bug1339.py, python3.10, cov=none: 0.180s
Median for bug1339.py, python3.10, cov=6.4.1: 0.421s
Median for bug1339.py, python3.11, cov=none: 0.141s
Median for bug1339.py, python3.11, cov=6.4.1: 0.835s
Median for bm_sudoku.py, python3.10, cov=none: 10.946s
Median for bm_sudoku.py, python3.10, cov=6.4.1: 28.293s
Median for bm_sudoku.py, python3.11, cov=none: 10.215s
Median for bm_sudoku.py, python3.11, cov=6.4.1: 60.590s
Median for bm_spectral_norm.py, python3.10, cov=none: 14.882s
Median for bm_spectral_norm.py, python3.10, cov=6.4.1: 37.359s
Median for bm_spectral_norm.py, python3.11, cov=none: 10.415s
Median for bm_spectral_norm.py, python3.11, cov=6.4.1: 76.129s
```
Diffstat (limited to 'lab/benchmark.py')
-rw-r--r-- | lab/benchmark.py | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/lab/benchmark.py b/lab/benchmark.py index 7a346aaf..ecda64c0 100644 --- a/lab/benchmark.py +++ b/lab/benchmark.py @@ -207,9 +207,14 @@ class ProjectAttrs(ToxProject): class AdHocProject(ProjectToTest): """A standalone program to run locally.""" - def __init__(self, python_file, pip_args=None): + def __init__(self, python_file, cur_dir=None, pip_args=None): super().__init__() self.python_file = Path(python_file) + if not self.python_file.exists(): + raise ValueError(f"Couldn't find {self.python_file} to run ad-hoc.") + self.cur_dir = Path(cur_dir or self.python_file.parent) + if not self.cur_dir.exists(): + raise ValueError(f"Couldn't find {self.cur_dir} to run in.") self.pip_args = pip_args self.slug = self.python_file.name @@ -220,19 +225,33 @@ class AdHocProject(ProjectToTest): env.shell.run_command(f"{env.python} -m pip install {self.pip_args}") def run_no_coverage(self, env): - with change_dir(self.python_file.parent): - env.shell.run_command(f"{env.python} {self.python_file.name}") + with change_dir(self.cur_dir): + env.shell.run_command(f"{env.python} {self.python_file}") return env.shell.last_duration def run_with_coverage(self, env, pip_args, cov_options): env.shell.run_command(f"{env.python} -m pip install {pip_args}") - with change_dir(self.python_file.parent): + with change_dir(self.cur_dir): env.shell.run_command( - f"{env.python} -m coverage run {self.python_file.name}" + f"{env.python} -m coverage run {self.python_file}" ) return env.shell.last_duration +class SlipcoverBenchmark(AdHocProject): + """ + For running code from the Slipcover benchmarks. + + Clone https://github.com/plasma-umass/slipcover to /src/slipcover + + """ + def __init__(self, python_file): + super().__init__( + python_file=f"/src/slipcover/benchmarks/{python_file}", + cur_dir="/src/slipcover", + pip_args="six pyperf", + ) + class PyVersion: """A version of Python to use.""" @@ -328,21 +347,24 @@ with change_dir(PERF_DIR): if 1: run_experiments( py_versions=[ - Python(3, 7), Python(3, 10), + Python(3, 11), ], cov_versions=[ - # ("none", None, None), - ("6.4 timid", "coverage==6.4", "timid=True"), - ( - "tip timid", - "git+https://github.com/nedbat/coveragepy.git@master", - "timid=True", - ), + ("none", None, None), + ("6.4.1", "coverage==6.4.1", ""), + # ( + # "tip timid", + # "git+https://github.com/nedbat/coveragepy.git@master", + # "timid=True", + # ), ], projects=[ - ProjectPytestHtml(), - ProjectAttrs(), + # ProjectPytestHtml(), + #ProjectAttrs(), + AdHocProject("/src/bugs/bug1339/bug1339.py"), + SlipcoverBenchmark("bm_sudoku.py"), + SlipcoverBenchmark("bm_spectral_norm.py"), ], num_runs=3, ) |