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:
1 parent
4b19245c6c
commit
833e1ec8dc
39 files changed
+543
-79
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import {FpsCounter} from './fps-counter';
|
||||
|
||||
describe('FpsCounter', () => {
|
||||
const FRAME_MS = 1000 / 60;
|
||||
|
||||
it('publishes 60 after the first 500 ms window and not before', () => {
|
||||
const counter = new FpsCounter();
|
||||
const at = (frame: number) => 1 + FRAME_MS * frame;
|
||||
|
||||
for (let frame = 0; at(frame) - 1 < 500; frame++) {
|
||||
counter.tick(at(frame));
|
||||
}
|
||||
expect(counter.fps()).toBe(0);
|
||||
|
||||
counter.tick(at(30)); // 30 ticks since the window opened, 500 ms elapsed
|
||||
expect(counter.fps()).toBe(60);
|
||||
});
|
||||
|
||||
it('reset sets the rate back to 0', () => {
|
||||
const counter = new FpsCounter();
|
||||
for (let i = 0; i <= 61; i++) {
|
||||
counter.tick(1 + FRAME_MS * i);
|
||||
}
|
||||
expect(counter.fps()).toBeGreaterThan(0);
|
||||
|
||||
counter.reset();
|
||||
|
||||
expect(counter.fps()).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user