How to use pytest_benchmark_update_json method in pytest-benchmark

Best Python code snippet using pytest-benchmark

hookspec.py

Source:hookspec.py Github

copy

Full Screen

...77 bench.has_error = False78 yield79 """80 pass81def pytest_benchmark_update_json(config, benchmarks, output_json):82 """83 Use this to add custom fields in the output JSON.84 Example:85 .. sourcecode:: python86 def pytest_benchmark_update_json(config, benchmarks, output_json):87 output_json['foo'] = 'bar'88 """89 pass90def pytest_benchmark_compare_machine_info(config, benchmarksession, machine_info, compared_benchmark):91 """92 You may want to use this hook to implement custom checks or abort execution.93 ``pytest-benchmark`` builtin hook does this:94 .. sourcecode:: python95 def pytest_benchmark_compare_machine_info(config, benchmarksession, machine_info, compared_benchmark):96 if compared_benchmark["machine_info"] != machine_info:97 benchmarksession.logger.warn(98 "Benchmark machine_info is different. Current: %s VS saved: %s." % (99 format_dict(machine_info),100 format_dict(compared_benchmark["machine_info"]),...

Full Screen

Full Screen

conftest.py

Source:conftest.py Github

copy

Full Screen

1import cpuinfo2def pytest_benchmark_update_json(config, benchmarks, output_json):3 """Calculate compression/decompression speed and add as extra_info"""4 for benchmark in output_json["benchmarks"]:5 if "data_size" in benchmark["extra_info"]:6 rate = benchmark["extra_info"].get("data_size", 0.0) / benchmark["stats"]["mean"]7 benchmark["extra_info"]["rate"] = rate8def pytest_benchmark_update_machine_info(config, machine_info):9 cpu_info = cpuinfo.get_cpu_info()10 brand = cpu_info.get("brand_raw", None)11 if brand is None:12 brand = "{} core(s) {} CPU ".format(cpu_info.get("count", "unknown"), cpu_info.get("arch", "unknown"))13 machine_info["cpu"]["brand"] = brand...

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