Skip to content

Commit 7c43ee4

Browse files
committed
Add more benchmarks
1 parent ea1b906 commit 7c43ee4

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

tests/benchmarking/test_benchmarking.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,52 @@ def test_build_django_from_cache(benchmark):
6868
benchmark(fn)
6969

7070

71+
def test_find_descendants(large_graph, benchmark):
72+
result = benchmark(large_graph.find_descendants, "mypackage")
73+
assert len(result) == 28222
74+
75+
76+
def test_find_downstream_modules(large_graph, benchmark):
77+
result = benchmark(large_graph.find_downstream_modules, DEEP_LAYERS[0], as_package=True)
78+
assert len(result) == 80
79+
80+
81+
def test_find_upstream_modules(large_graph, benchmark):
82+
result = benchmark(large_graph.find_upstream_modules, DEEP_LAYERS[0], as_package=True)
83+
assert len(result) == 2159
84+
85+
86+
def test_find_shortest_chain(large_graph, benchmark):
87+
result = benchmark(large_graph.find_shortest_chain, DEEP_LAYERS[0], DEEP_LAYERS[1])
88+
assert result is not None and len(result) == 5
89+
90+
91+
def test_find_shortest_chain__no_chain(large_graph, benchmark):
92+
result = benchmark(
93+
large_graph.find_shortest_chain,
94+
DEEP_LAYERS[0],
95+
"mypackage.data.vendors.4053192739.6373932949",
96+
)
97+
assert result is None
98+
99+
100+
def test_find_shortest_chains(large_graph, benchmark):
101+
result = benchmark(
102+
large_graph.find_shortest_chains, DEEP_LAYERS[0], DEEP_LAYERS[1], as_packages=True
103+
)
104+
assert result is not None and len(result) == 1 and len(list(result)[0]) == 5
105+
106+
107+
def test_find_shortest_chains__no_chain(large_graph, benchmark):
108+
result = benchmark(
109+
large_graph.find_shortest_chains,
110+
DEEP_LAYERS[0],
111+
"mypackage.data.vendors.4053192739.6373932949",
112+
as_packages=True,
113+
)
114+
assert result == set()
115+
116+
71117
def test_top_level_large_graph(large_graph, benchmark):
72118
result = benchmark(
73119
lambda: large_graph.find_illegal_dependencies_for_layers(

0 commit comments

Comments
 (0)