镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ pyperformance/tests/data/cpython/

# Created by the tox program
.tox/

# coverage
.coverage
1 change: 1 addition & 0 deletions pyperformance/data-files/benchmarks/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ async_tree <local>
async_tree_cpu_io_mixed <local:async_tree>
async_tree_io <local:async_tree>
async_tree_memoization <local:async_tree>
coverage <local>
generators <local>
chameleon <local>
chaos <local>
Expand Down
12 changes: 12 additions & 0 deletions pyperformance/data-files/benchmarks/bm_coverage/pyproject.toml
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"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage==6.4.1
29 changes: 29 additions & 0 deletions pyperformance/data-files/benchmarks/bm_coverage/run_benchmark.py
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)