MCPcopy Create free account
hub / github.com/tox-dev/filelock / _timed

Function _timed

tasks/benchmark.py:173–181  ·  view source on GitHub ↗
(name: str, run: Callable[[], object], *, unit: str, scale: float)

Source from the content-addressed store, hash-verified

171
172
173def _timed(name: str, run: Callable[[], object], *, unit: str, scale: float) -> Sample:
174 warmup: int = 20
175 for _ in range(warmup):
176 run()
177 iterations: int = 200
178 durations = [_one(run) for _ in range(iterations)]
179 return Sample(
180 name=name, median=statistics.median(durations) * scale, p95=_percentile(durations, 95) * scale, unit=unit
181 )
182
183
184def _one(run: Callable[[], object]) -> float:

Callers 2

mainFunction · 0.85
_uncontendedFunction · 0.85

Calls 4

_oneFunction · 0.85
SampleClass · 0.85
_percentileFunction · 0.85
runFunction · 0.50

Tested by

no test coverage detected