File tree Expand file tree Collapse file tree 5 files changed +46
-0
lines changed
pyperformance/data-files/benchmarks Expand file tree Collapse file tree 5 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,6 @@ pyperformance/tests/data/cpython/
2121
2222# Created by the tox program
2323.tox /
24+
25+ # coverage
26+ .coverage
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ async_tree <local>
66async_tree_cpu_io_mixed <local:async_tree>
77async_tree_io <local:async_tree>
88async_tree_memoization <local:async_tree>
9+ coverage <local>
910generators <local>
1011chameleon <local>
1112chaos <local>
Original file line number Diff line number Diff line change 1+ [project ]
2+ name = " pyperformance_bm_coverage"
3+ requires-python = " >=3.8"
4+ dependencies = [
5+ " pyperf" ,
6+ " coverage" ,
7+ ]
8+ urls = {repository = " https://github.com/python/pyperformance" }
9+ dynamic = [" version" ]
10+
11+ [tool .pyperformance ]
12+ name = " coverage"
Original file line number Diff line number Diff line change 1+ coverage == 6.4.1
Original file line number Diff line number Diff line change 1+ """
2+ Benchmark coverage performance with a recursive fibonacci function.
3+ """
4+
5+ import coverage
6+ import pyperf
7+
8+
9+ def fibonacci (n : int ) -> int :
10+ if n <= 1 :
11+ return n
12+ return fibonacci (n - 1 ) + fibonacci (n - 2 )
13+
14+
15+ def bench_coverage (loops : int ) -> None :
16+ range_it = range (loops )
17+ cov = coverage .Coverage ()
18+ cov .start ()
19+ t0 = pyperf .perf_counter ()
20+ for _ in range_it :
21+ fibonacci (25 )
22+ cov .stop ()
23+ return pyperf .perf_counter () - t0
24+
25+
26+ if __name__ == "__main__" :
27+ runner = pyperf .Runner ()
28+ runner .metadata ['description' ] = "Benchmark coverage"
29+ runner .bench_time_func ('coverage' , bench_coverage )
You can’t perform that action at this time.
0 commit comments