(name: str, run: Callable[[], object], *, unit: str, scale: float)
| 171 | |
| 172 | |
| 173 | def _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 | |
| 184 | def _one(run: Callable[[], object]) -> float: |
no test coverage detected