Phase 10: Monitoring and automated benchmarks

10.1: Add Criterion dev-dependency and benchmarks for:
  - matching_rules (100 rules)
  - ComputedStyle::compute (empty, 5 props)
  - resolve_string (no vars, 1 var, 3 vars)

10.3: Add --perf CLI flag and src/perf.rs module:
  - PerfScope drop-guard timed scopes (vdom, style, render)
  - Instrumented: VDOM eval (app.rs update), render (app.rs view),
    style matching (style.rs compute_cached)
  - Per-frame report printed to stderr at end of view()

10.2+10.4: Threshold check in perf report:
  - Prints warning if total > 16ms (60 FPS frame budget)

Refactor: Move Message enum to lib.rs so benchmarks can import
the public API. Added lib.rs as library root.
This commit is contained in:
Glint Dev
2026-07-24 19:58:58 +03:00
parent b6fa841d11
commit 938f05f59d
8 changed files with 389 additions and 26 deletions

View File

@@ -821,6 +821,7 @@ impl StyleSheet {
props: &[(Cow<'_, str>, Cow<'_, str>)],
matched_sheets: &[&'a HashMap<String, String>],
) -> ComputedStyle {
let _scope = crate::perf::PerfScope::new("style");
let epoch = self.epoch;
self.cache.lock().unwrap().get_or_compute(type_name, props, epoch, matched_sheets)
}