aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pluggy/py2/tests/benchmark.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/python/pluggy/py2/tests/benchmark.py
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
downloadydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/pluggy/py2/tests/benchmark.py')
-rw-r--r--contrib/python/pluggy/py2/tests/benchmark.py102
1 files changed, 51 insertions, 51 deletions
diff --git a/contrib/python/pluggy/py2/tests/benchmark.py b/contrib/python/pluggy/py2/tests/benchmark.py
index aa8de92911..cb99660adb 100644
--- a/contrib/python/pluggy/py2/tests/benchmark.py
+++ b/contrib/python/pluggy/py2/tests/benchmark.py
@@ -1,51 +1,51 @@
-"""
-Benchmarking and performance tests.
-"""
-import pytest
-from pluggy import HookspecMarker, HookimplMarker
-from pluggy.hooks import HookImpl
-from pluggy.callers import _multicall, _legacymulticall
-
-hookspec = HookspecMarker("example")
-hookimpl = HookimplMarker("example")
-
-
-def MC(methods, kwargs, callertype, firstresult=False):
- hookfuncs = []
- for method in methods:
- f = HookImpl(None, "<temp>", method, method.example_impl)
- hookfuncs.append(f)
- return callertype(hookfuncs, kwargs, firstresult=firstresult)
-
-
-@hookimpl
-def hook(arg1, arg2, arg3):
- return arg1, arg2, arg3
-
-
-@hookimpl(hookwrapper=True)
-def wrapper(arg1, arg2, arg3):
- yield
-
-
-@pytest.fixture(params=[10, 100], ids="hooks={}".format)
-def hooks(request):
- return [hook for i in range(request.param)]
-
-
-@pytest.fixture(params=[10, 100], ids="wrappers={}".format)
-def wrappers(request):
- return [wrapper for i in range(request.param)]
-
-
-@pytest.fixture(params=[_multicall, _legacymulticall], ids=lambda item: item.__name__)
-def callertype(request):
- return request.param
-
-
-def inner_exec(methods, callertype):
- return MC(methods, {"arg1": 1, "arg2": 2, "arg3": 3}, callertype)
-
-
-def test_hook_and_wrappers_speed(benchmark, hooks, wrappers, callertype):
- benchmark(inner_exec, hooks + wrappers, callertype)
+"""
+Benchmarking and performance tests.
+"""
+import pytest
+from pluggy import HookspecMarker, HookimplMarker
+from pluggy.hooks import HookImpl
+from pluggy.callers import _multicall, _legacymulticall
+
+hookspec = HookspecMarker("example")
+hookimpl = HookimplMarker("example")
+
+
+def MC(methods, kwargs, callertype, firstresult=False):
+ hookfuncs = []
+ for method in methods:
+ f = HookImpl(None, "<temp>", method, method.example_impl)
+ hookfuncs.append(f)
+ return callertype(hookfuncs, kwargs, firstresult=firstresult)
+
+
+@hookimpl
+def hook(arg1, arg2, arg3):
+ return arg1, arg2, arg3
+
+
+@hookimpl(hookwrapper=True)
+def wrapper(arg1, arg2, arg3):
+ yield
+
+
+@pytest.fixture(params=[10, 100], ids="hooks={}".format)
+def hooks(request):
+ return [hook for i in range(request.param)]
+
+
+@pytest.fixture(params=[10, 100], ids="wrappers={}".format)
+def wrappers(request):
+ return [wrapper for i in range(request.param)]
+
+
+@pytest.fixture(params=[_multicall, _legacymulticall], ids=lambda item: item.__name__)
+def callertype(request):
+ return request.param
+
+
+def inner_exec(methods, callertype):
+ return MC(methods, {"arg1": 1, "arg2": 2, "arg3": 3}, callertype)
+
+
+def test_hook_and_wrappers_speed(benchmark, hooks, wrappers, callertype):
+ benchmark(inner_exec, hooks + wrappers, callertype)