FPS being less than absolute FPS

I’ve been trying out a few heavy duty experiments with Babylon.

On a low end device, this causes the fps to drop to ~14 sometimes. I do see that the absolute fps is like 70-80.

Wanted to understand the difference between the two and what might cause the FPS to drop below the absolute FPS.

getFps is a rolling average over 30 frames, whereas the other one is an average over the last second meaning over the last seconds we have an avg of 70 80 fps whereas the rolling average over the last 30 frames is about 14

Hi @sebavan, is there an easy way to get the absoluteFps in BabylonJS?

I only find this but not sure this is the best reliable way?

  getAbsoluteFps(): number {
        let defaultFrameTime = this.engine.getTimeStep();
        return (1000.0 / defaultFrameTime);
    }

Thanks a lot for you help,
Pichou :wink:

You could also do smthg similar to our AbsoluteFpsStrategy

public static AbsoluteFpsStrategy(): PerfStrategyInitialization {
        return (scene) => {
            let startTime = PrecisionDate.Now;
            let timeTaken = 1;
            const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {
                startTime = PrecisionDate.Now;
            });

            const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {
                timeTaken = PrecisionDate.Now - startTime;
            });

            return {
                id: "Absolute FPS",
                getData: () => 1000.0 / timeTaken,
                dispose: () => {
                    scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);
                    scene.onAfterRenderObservable.remove(onAfterRenderObserver);
                },
            };
        };
    }
1 Like