|
2 | 2 | Benchmarking and performance tests.
|
3 | 3 | """
|
4 | 4 | import pytest
|
5 |
| -from pluggy import _MultiCall, HookImpl, HookspecMarker, HookimplMarker |
| 5 | +from pluggy import (_MultiCall, _LegacyMultiCall, HookImpl, HookspecMarker, |
| 6 | + HookimplMarker) |
6 | 7 |
|
7 | 8 | hookspec = HookspecMarker("example")
|
8 | 9 | hookimpl = HookimplMarker("example")
|
9 | 10 |
|
10 | 11 |
|
11 |
| -def MC(methods, kwargs, firstresult=False): |
| 12 | +def MC(methods, kwargs, callertype, firstresult=False): |
12 | 13 | hookfuncs = []
|
13 | 14 | for method in methods:
|
14 | 15 | f = HookImpl(None, "<temp>", method, method.example_impl)
|
15 | 16 | hookfuncs.append(f)
|
16 |
| - return _MultiCall(hookfuncs, kwargs, {"firstresult": firstresult}) |
| 17 | + return callertype(hookfuncs, kwargs, {"firstresult": firstresult}) |
17 | 18 |
|
18 | 19 |
|
19 | 20 | @hookimpl
|
@@ -42,9 +43,17 @@ def wrappers(request):
|
42 | 43 | return [wrapper for i in range(request.param)]
|
43 | 44 |
|
44 | 45 |
|
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() |
47 | 56 |
|
48 | 57 |
|
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