#533 added a normalize_perf exercise that repeats the operation 1000× to produce a measurable timing:
def normalize_perf():
# python/cpython#143658
import importlib_metadata # end warmup
# operation completes in < 1ms, so repeat it to get visibility
# https://github.com/jaraco/pytest-perf/issues/12
for _ in range(1000):
importlib_metadata.Prepared.normalize('sample')
The loop exists only because a single Prepared.normalize('sample') call runs well under a microsecond — below the resolution pytest-perf had at the time. It parsed timeit output into a microsecond-resolution datetime.timedelta, so sub-microsecond timings rounded to zero and the control/experiment comparison was meaningless.
As of pytest-perf 0.16.0, timings are compared with nanosecond precision (via tempora.Duration), resolving jaraco/pytest-perf#18. The amplification loop is no longer needed; normalize_perf can exercise a single call:
def normalize_perf():
import importlib_metadata # end warmup
importlib_metadata.Prepared.normalize('sample')
This would require pytest-perf >= 0.16 for the perf run.
#533 added a
normalize_perfexercise that repeats the operation 1000× to produce a measurable timing:The loop exists only because a single
Prepared.normalize('sample')call runs well under a microsecond — below the resolution pytest-perf had at the time. It parsedtimeitoutput into a microsecond-resolutiondatetime.timedelta, so sub-microsecond timings rounded to zero and the control/experiment comparison was meaningless.As of pytest-perf 0.16.0, timings are compared with nanosecond precision (via
tempora.Duration), resolving jaraco/pytest-perf#18. The amplification loop is no longer needed;normalize_perfcan exercise a single call:This would require pytest-perf >= 0.16 for the perf run.