Skip to content

Commit 21fd6c4

Browse files
author
Tyler Goodlet
committed
Parametrize over legacy versus new multicall types
1 parent 09d7589 commit 21fd6c4

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

testing/benchmark.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
Benchmarking and performance tests.
33
"""
44
import pytest
5-
from pluggy import _MultiCall, HookImpl, HookspecMarker, HookimplMarker
5+
from pluggy import (_MultiCall, _LegacyMultiCall, HookImpl, HookspecMarker,
6+
HookimplMarker)
67

78
hookspec = HookspecMarker("example")
89
hookimpl = HookimplMarker("example")
910

1011

11-
def MC(methods, kwargs, firstresult=False):
12+
def MC(methods, kwargs, callertype, firstresult=False):
1213
hookfuncs = []
1314
for method in methods:
1415
f = HookImpl(None, "<temp>", method, method.example_impl)
1516
hookfuncs.append(f)
16-
return _MultiCall(hookfuncs, kwargs, {"firstresult": firstresult})
17+
return callertype(hookfuncs, kwargs, {"firstresult": firstresult})
1718

1819

1920
@hookimpl
@@ -42,9 +43,17 @@ def wrappers(request):
4243
return [wrapper for i in range(request.param)]
4344

4445

45-
def inner_exec(methods):
46-
return MC(methods, {'arg1': 1, 'arg2': 2, 'arg3': 3}).execute()
46+
@pytest.fixture(
47+
params=[_MultiCall, _LegacyMultiCall],
48+
ids=lambda item: item.__name__
49+
)
50+
def callertype(request):
51+
return request.param
52+
53+
54+
def inner_exec(methods, callertype):
55+
return MC(methods, {'arg1': 1, 'arg2': 2, 'arg3': 3}, callertype).execute()
4756

4857

49-
def test_hook_and_wrappers_speed(benchmark, hooks, wrappers):
50-
benchmark(inner_exec, hooks + wrappers)
58+
def test_hook_and_wrappers_speed(benchmark, hooks, wrappers, callertype):
59+
benchmark(inner_exec, hooks + wrappers, callertype)

0 commit comments

Comments
 (0)