| 1 | #!/usr/bin/env bash |
| 2 | set -e |
| 3 | export PYTHONPYCACHEPREFIX="$(mktemp -d)" |
| 4 | python3 - <<'PY' |
| 5 | import timings, budget, alerts |
| 6 | assert not hasattr(timings, "SLOW_MS") and not hasattr(timings, "BUDGET_MS") |
| 7 | e = timings.record(1.5) |
| 8 | assert abs(e["elapsed_s"] - 1.5) < 1e-9 |
| 9 | assert alerts.is_slow(timings.record(2.5)) |
| 10 | assert not alerts.is_slow(timings.record(1.0)) |
| 11 | assert budget.within_budget([timings.record(30.0), timings.record(29.0)]) |
| 12 | assert not budget.within_budget([timings.record(61.0)]) |
| 13 | PY |
| 14 |