diff --git a/docs/configuration.md b/docs/configuration.md index 577a51d..e32a555 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -128,6 +128,7 @@ When enabled, press `Cmd+Shift+M` to toggle the metrics overlay in the bottom-ri - **Frames**: Total rendered frame count - **FPS**: Frames per second - **Glyph cache**: Number of cached glyph textures +- **Glyph hit rate**: Cache hit percentage (hits / total accesses) - **Glyph hits/s**: Glyph cache hits per second - **Glyph misses/s**: Glyph cache misses per second - **Glyph evictions/s**: Glyph cache evictions per second diff --git a/src/ui/components/metrics_overlay.zig b/src/ui/components/metrics_overlay.zig index a0bb42b..385d9e7 100644 --- a/src/ui/components/metrics_overlay.zig +++ b/src/ui/components/metrics_overlay.zig @@ -184,6 +184,11 @@ pub const MetricsOverlayComponent = struct { lines[line_count] = std.fmt.bufPrint(&line_bufs[line_count], "Glyph cache: {d}", .{cache_size}) catch "Glyph cache: ?"; line_count += 1; + const total_accesses = hit_rate + miss_rate; + const hit_pct: f64 = if (total_accesses > 0) (hit_rate / total_accesses) * 100.0 else 0.0; + lines[line_count] = std.fmt.bufPrint(&line_bufs[line_count], "Glyph hit rate: {d:.1}%", .{hit_pct}) catch "Glyph hit rate: ?"; + line_count += 1; + lines[line_count] = std.fmt.bufPrint(&line_bufs[line_count], "Glyph hits/s: {d:.1}", .{hit_rate}) catch "Glyph hits/s: ?"; line_count += 1;