core/utils/performance_budget library
Pure-Dart performance budget / regression-check framework (FEAT-80).
Consumes already-measured PerformanceBudgetMetrics — produced by
tool/performance_budget_check.dart from a real headless benchmark
and/or a real-device smoke-test run, never fabricated here — and checks
them against a BudgetPolicy list, optionally comparing against a
committed PerformanceBudgetMetric baseline for regression detection.
No I/O, no Flutter dependency.
Honesty rules baked into checkPerformanceBudgets:
- A metric a policy names but no measurement was supplied for is a PerformanceBudgetViolationKind.missingMeasurement failure, never a silent skip — an unmeasured budget is not a passed budget.
- A policy that requires MeasurementSource.realDevice fails outright (PerformanceBudgetViolationKind.wrongSource) if only a MeasurementSource.hostHeadless value was supplied for that metric — a host number never silently counts as device proof.
Classes
- BudgetPolicy
- One budget rule a named metric must satisfy.
- PerformanceBudgetMetric
-
One measured value — e.g. an allocation-reduction percentage from
tool/object_pool_benchmark.dart, or a real-device app-boot wall time. - PerformanceBudgetResult
- PerformanceBudgetViolation
Enums
- BudgetDirection
- Whether a budget's BudgetPolicy.limit is a ceiling or a floor.
- MeasurementSource
- Where a PerformanceBudgetMetric's value actually came from.
- PerformanceBudgetViolationKind
Functions
-
checkPerformanceBudgets(
{required List< PerformanceBudgetMetric> measurements, required List<BudgetPolicy> policies, List<PerformanceBudgetMetric> baseline = const [], int? nowMs}) → PerformanceBudgetResult -
Checks
measurementsagainstpolicies. Each policy fails on at most one PerformanceBudgetViolation (checked in the order: missing, wrong source, stale, over budget, regression) — stops at the first that applies rather than piling up redundant complaints about one metric.