How to use pytest_benchmark_scale_unit method in pytest-benchmark

Best Python code snippet using pytest-benchmark

hookspec.py

Source:hookspec.py Github

copy

Full Screen

1def pytest_benchmark_scale_unit(config, unit, benchmarks, best, worst, sort):2 """3 To have custom time scaling do something like this:4 .. sourcecode:: python5 def pytest_benchmark_scale_unit(config, unit, benchmarks, best, worst, sort):6 if unit == 'seconds':7 prefix = ''8 scale = 1.09 elif unit == 'operations':10 prefix = 'K'11 scale = 0.00112 else:13 raise RuntimeError("Unexpected measurement unit %r" % unit)14 return prefix, scale15 """16 pass17def pytest_benchmark_generate_machine_info(config):18 """19 To completely replace the generated machine_info do something like this:...

Full Screen

Full Screen

pytest_util.py

Source:pytest_util.py Github

copy

Full Screen

...48 UNIT_PREFIX = "n"49 else:50 raise ValueError("Invalid unit: %s" % (PYTEST_BENCH_FORCE_UNIT))51if PYTEST_BENCH_FORCE_UNIT:52 def pytest_benchmark_scale_unit(config, unit, benchmarks, best, worst, sort):53 """54 Custom scale function to ensure we use consistent units for all the micro benchmarks.55 We convert timing data to milliseconds and "throughput" / operations data to 1000s56 of operations per second.57 """58 if unit == "seconds":59 prefix = UNIT_PREFIX60 scale = UNIT_SCALE61 elif unit == "operations":62 prefix = "K"63 scale = 0.00164 else:65 raise RuntimeError("Unexpected measurement unit %r" % unit)66 return prefix, scale67else:68 def pytest_benchmark_scale_unit(config, unit, benchmarks, best, worst, sort):69 pass70@pytest.mark.hookwrapper71def pytest_benchmark_generate_json(72 config, benchmarks, include_data, machine_info, commit_info73):74 """75 Hook which makes sure we include custom metrics such as compression_ratio in the output JSON.76 In addition to that, it also adds "submit_result_to_codespeed" to the "options" dict if the77 original function is decorated with "submit_result_to_codespeed" decorator.78 """79 for benchmark in benchmarks:80 submit_result_to_codespeed = getattr(81 benchmark.fixture, "submit_result_to_codespeed", False82 )...

Full Screen

Full Screen

conftest.py

Source:conftest.py Github

copy

Full Screen

1# Copyright 2014-2020 Scalyr Inc.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14from __future__ import absolute_import15from scalyr_agent.pytest_util import pytest_benchmark_scale_unit # NOQA16from scalyr_agent.pytest_util import pytest_benchmark_generate_json # NOQA...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytest-benchmark automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful