How to use _raw_pedantic method in pytest-benchmark

Best Python code snippet using pytest-benchmark

fixture.py

Source:fixture.py Github

copy

Full Screen

...119 raise FixtureAlreadyUsed(120 "Fixture can only be used once. Previously it was used in %s mode." % self._mode)121 try:122 self._mode = 'benchmark.pedantic(...)'123 return self._raw_pedantic(target, args=args, kwargs=kwargs, setup=setup, rounds=rounds,124 warmup_rounds=warmup_rounds, iterations=iterations)125 except Exception:126 self.has_error = True127 raise128 def _raw(self, function_to_benchmark, *args, **kwargs):129 if self.enabled:130 runner = self._make_runner(function_to_benchmark, args, kwargs)131 duration, iterations, loops_range = self._calibrate_timer(runner)132 # Choose how many time we must repeat the test133 rounds = int(ceil(self._max_time / duration))134 rounds = max(rounds, self._min_rounds)135 rounds = min(rounds, sys.maxsize)136 stats = self._make_stats(iterations)137 self._logger.debug(" Running %s rounds x %s iterations ..." % (rounds, iterations), yellow=True, bold=True)138 run_start = time.time()139 if self._warmup:140 warmup_rounds = min(rounds, max(1, int(self._warmup / iterations)))141 self._logger.debug(" Warmup %s rounds x %s iterations ..." % (warmup_rounds, iterations))142 for _ in XRANGE(warmup_rounds):143 runner(loops_range)144 for _ in XRANGE(rounds):145 stats.update(runner(loops_range))146 self._logger.debug(" Ran for %ss." % format_time(time.time() - run_start), yellow=True, bold=True)147 if self.enabled and self.cprofile:148 profile = cProfile.Profile()149 function_result = profile.runcall(function_to_benchmark, *args, **kwargs)150 self.stats.cprofile_stats = pstats.Stats(profile)151 else:152 function_result = function_to_benchmark(*args, **kwargs)153 return function_result154 def _raw_pedantic(self, target, args=(), kwargs=None, setup=None, rounds=1, warmup_rounds=0, iterations=1):155 if kwargs is None:156 kwargs = {}157 has_args = bool(args or kwargs)158 if not isinstance(iterations, INT) or iterations < 1:159 raise ValueError("Must have positive int for `iterations`.")160 if not isinstance(rounds, INT) or rounds < 1:161 raise ValueError("Must have positive int for `rounds`.")162 if not isinstance(warmup_rounds, INT) or warmup_rounds < 0:163 raise ValueError("Must have positive int for `warmup_rounds`.")164 if iterations > 1 and setup:165 raise ValueError("Can't use more than 1 `iterations` with a `setup` function.")166 def make_arguments(args=args, kwargs=kwargs):167 if setup:168 maybe_args = setup()...

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