How to use display_cprofile method in pytest-benchmark

Best Python code snippet using pytest-benchmark

session.py

Source:session.py Github

copy

Full Screen

...197 scale_unit=partial(self.config.hook.pytest_benchmark_scale_unit, config=self.config),198 )199 results_table.display(tr, self.groups)200 self.check_regressions()201 self.display_cprofile(tr)202 def check_regressions(self):203 if self.compare_fail and not self.compared_mapping:204 raise pytest.UsageError("--benchmark-compare-fail requires valid --benchmark-compare.")205 if self.performance_regressions:206 self.logger.error("Performance has regressed:\n%s" % "\n".join(207 "\t%s - %s" % line for line in self.performance_regressions208 ))209 raise PerformanceRegression("Performance has regressed.")210 def display_cprofile(self, tr):211 section_displayed = False212 for group in self.groups:213 group_name, benchmarks = group214 for benchmark in benchmarks:215 if "cprofile" in benchmark:216 if not section_displayed:217 tr.section("cProfile (time in s)", sep="-", yellow=True)218 section_displayed = True219 tr.write(benchmark["fullname"], yellow=True)220 if benchmark["source"]:221 tr.write_line(" ({})".format((benchmark["source"])))222 else:223 tr.write("\n")224 tr.write_line("ncalls\ttottime\tpercall\tcumtime\tpercall\tfilename:lineno(function)")...

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