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);
                },
            };
        };
    }
2 Likes

@PichouPichou we now have a super easy way to track absolute FPS with our Performance Profiler :slight_smile: Introducing the Performance Profiler!

3 Likes

Awesome Thank you!

2 Likes

I’d like to bounce on this old topic, because I have the same question and didn’t really find my answer here. I’m not having issues measuring the one or the other. I’m just not satisfied with the answer.
I have been looking at performance for 30sec. and I got the same results between FPS and absoluteFPS all the time, with twice the numbers for absoluteFPS.
What could be the cause of limitating the FPS (since I haven’t done any instruction for this, as far as I know). Could it be related to physics and the ammoJS plugin? How can I ensure I got max FPS (even with drops)? As you guys know from my posts by now, I’m no ENG, just a simple designer and PM. I’d still like to get a better understanding of this, so if somebody can point me towards the right direction or some articles, would be much appreciated. Thanks in advance,

Browsers are limiting your FPS to prevent any waste of frames as your screen would not be able to render them anyway.

So in the most common case, your browser will target 60FPS (not speaking VR or fancy monitors here). In this case the RequestAnimationFrame callback used to render frames will be called at 60 FPS only which give you 16ms to do everything you need. Your code on the other hand might run faster, lets say in ms, so basically here you could run at 250 FPS about which is what we call absoluteFPS.

Thank you. I do totally understand this part, but this is not my case. The code runs below 60fps (especially on older systems/GPU). I get things like an absolute FPS of 54 and an FPS of 25. With fairly stable numbers.

Absolute FPS does not account for GPU spent time which in your case might be half a frame reducing then your total FPS abilities.

Oh, amazing. Thx so much for the info. I was indeed testing on a very old system (a decade old 1GB average at that time GPU) as compared to a fairly new (medium range) 4GB GPU from late 2019. I do now much better understand why I get this discrepancy.

I would have another question though: How should I understand the interframe calc, is this also “disregarding” GPU spent time? What could be the reason of getting (sometimes heavy) drops due to high interframe happening now or then (without actually interacting with the scene)? The reason for this all questionning is that I’m trying to make an update of my first real BJS demo (the snowball demo). So far, I got through about 60% of the process and already tripled the original FPS :smiley: Reworking this first scene, that was probably oversized for my (absence of) knowledge of the moment :wink: is a nightmare :face_with_open_eyes_and_hand_over_mouth: but I still have hopes I can make it through before the release of v5 :yum:

GPU + anything not related to babylon as well like GC, css anims… and such + idle time to wait on vsync :slight_smile: