Skip to content

Commit

Permalink
Merge pull request #180 from Peter554/add-benchmark.module-in-graph-m…
Browse files Browse the repository at this point in the history
…odules

Add benchmark for "..." in graph.modules
  • Loading branch information
seddonym authored Feb 6, 2025
2 parents 0523253 + f99d32d commit 06401f4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/benchmarking/test_benchmarking.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def large_graph():
f"{DEEP_PACKAGE}.application.3242334296.2454157946",
)


TOP_LEVEL_PACKAGE_DEPENDENCIES = {
PackageDependency(
importer="mypackage.domain",
Expand Down Expand Up @@ -423,3 +422,19 @@ def test_no_chains(self, large_graph, benchmark):

def test_copy_graph(large_graph, benchmark):
_run_benchmark(benchmark, lambda: deepcopy(large_graph))


def test_graph_contains_module(large_graph, benchmark):
def f(n):
for i in range(n):
_ = f"foo{i}" in large_graph.modules

_run_benchmark(benchmark, f, 100)


def test_iterate_over_modules_in_graph(large_graph, benchmark):
def f():
for module in large_graph.modules:
_ = module

_run_benchmark(benchmark, f)

0 comments on commit 06401f4

Please # to comment.