feat(algorithms): add live metrics to algorithm pages

Each algorithm page shows its numbers with app-metrics.
FpsCounter publishes a rate every 500 ms, not every frame.
Fractal 2D reset now also resets the zoom slider.
This commit is contained in:
lobo committed 2026-10-21 14:35:15 +02:00
1 parent 4b19245c6c
commit 833e1ec8dc
39 files changed
+543 -79

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import {signal} from '@angular/core';
/** Counts ticks and publishes a rate a few times per second, so the display never costs frame time. */
export class FpsCounter {
readonly fps = signal(0);
private ticks = 0;
private windowStart = 0;
constructor(private readonly intervalMs = 500) {}
tick(now: number = performance.now()): void {
if (this.windowStart === 0) {
this.windowStart = now;
return;
}
this.ticks++;
const elapsed = now - this.windowStart;
if (elapsed >= this.intervalMs) {
this.fps.set(Math.round(this.ticks * 1000 / elapsed));
this.ticks = 0;
this.windowStart = now;
}
}
reset(): void {
this.ticks = 0;
this.windowStart = 0;
this.fps.set(0);
}
}