Skip to content

Commit 81daa0d

Browse files
authored
Merge pull request #171 from seddonym/dont-cache-in-benchmark
Improve cache handling in benchmark tests
2 parents 9df4577 + 350b603 commit 81daa0d

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/benchmarking/test_benchmarking.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,30 @@ def large_graph():
3434
)
3535

3636

37-
def test_build_django(benchmark):
37+
def test_build_django_uncached(benchmark):
3838
"""
3939
Benchmarks building a graph of real package - in this case Django.
40+
41+
In this benchmark, the cache is turned off.
42+
"""
43+
fn = lambda: grimp.build_graph("django", cache_dir=None)
44+
if hasattr(benchmark, "pendantic"):
45+
# Running with pytest-benchmark
46+
benchmark.pedantic(fn, rounds=3)
47+
else:
48+
# Running with codspeed.
49+
benchmark(fn)
50+
51+
52+
def test_build_django_from_cache(benchmark):
4053
"""
54+
Benchmarks building a graph of real package - in this case Django.
55+
56+
This benchmark uses the cache.
57+
"""
58+
# Populate the cache first, before beginning the benchmark.
59+
grimp.build_graph("django")
60+
4161
fn = lambda: grimp.build_graph("django")
4262
if hasattr(benchmark, "pendantic"):
4363
# Running with pytest-benchmark

0 commit comments

Comments
 (0)