-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f195616
commit 01d3e81
Showing
5 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,6 @@ pyperformance/tests/data/cpython/ | |
|
||
# Created by the tox program | ||
.tox/ | ||
|
||
# coverage | ||
.coverage |
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
12 changes: 12 additions & 0 deletions
12
pyperformance/data-files/benchmarks/bm_coverage/pyproject.toml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[project] | ||
name = "pyperformance_bm_coverage" | ||
requires-python = ">=3.8" | ||
dependencies = [ | ||
"pyperf", | ||
"coverage", | ||
] | ||
urls = {repository = "https://github.com/python/pyperformance"} | ||
dynamic = ["version"] | ||
|
||
[tool.pyperformance] | ||
name = "coverage" |
1 change: 1 addition & 0 deletions
1
pyperformance/data-files/benchmarks/bm_coverage/requirements.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
coverage==6.4.1 |
29 changes: 29 additions & 0 deletions
29
pyperformance/data-files/benchmarks/bm_coverage/run_benchmark.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
Benchmark coverage performance with a recursive fibonacci function. | ||
""" | ||
|
||
import coverage | ||
import pyperf | ||
|
||
|
||
def fibonacci(n: int) -> int: | ||
if n <= 1: | ||
return n | ||
return fibonacci(n - 1) + fibonacci(n - 2) | ||
|
||
|
||
def bench_coverage(loops: int) -> None: | ||
range_it = range(loops) | ||
cov = coverage.Coverage() | ||
cov.start() | ||
t0 = pyperf.perf_counter() | ||
for _ in range_it: | ||
fibonacci(25) | ||
cov.stop() | ||
return pyperf.perf_counter() - t0 | ||
|
||
|
||
if __name__ == "__main__": | ||
runner = pyperf.Runner() | ||
runner.metadata['description'] = "Benchmark coverage" | ||
runner.bench_time_func('coverage', bench_coverage) |