# Running null engine on specific framerate

**URL:** <https://forum.babylonjs.com/t/running-null-engine-on-specific-framerate/58708>\
**Category:** Questions\
**Tags:** engine, nullengine, fps\
**Created:** [May 28, 2025, 8:49pm UTC](https://forum.babylonjs.com/t/running-null-engine-on-specific-framerate/58708 "2025-05-28T20:49:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Panuchka](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/panuchka/32/12054_2.png) [@Panuchka](https://forum.babylonjs.com/u/Panuchka)\
**Post date:** [May 28, 2025, 8:49pm UTC](https://forum.babylonjs.com/t/running-null-engine-on-specific-framerate/58708/1 "2025-05-28T20:49:05Z")

</div>

Hi everyone!

Quick question! I’m running NullEngine server side with Bun, and I’m trying to optimize my CPU usage, since servers cost money 💸

I’m struggling to understand how to run the render loop correctly with lower fps. Usually the loop target I guess is 60fps, but I would like to try it 20fps so I guess the cpu time would be less.

Here is the basic initialization code I use now to try and get things 20fps:

```ts
const options: NullEngineOptions = {
  renderHeight: 0,
  renderWidth: 0,
  textureSize: 0,
  lockstepMaxSteps: 4,
  deterministicLockstep: true,
  timeStep: 1 / 20,
}
this.engine = new NullEngine(options)
this.scene.executeWhenReady(async () => {
  this.engine.runRenderLoop(() => {
     // Run logic systems here
     
     // This prints ~30-34
     console.log(this.engine.getFps().toFixed())
    
     // Render
     this.scene.render(false, false)
  })
})

```

Can someone instruct how I would manage to do this, would be fun to try something like running the server 10fps and see what happens 😃 I am also using physics and recast navigation on server side.

It seems that whatever I now do, the `engine.getFps()` seems unchanged… Also, is the `this.engine.maxFPS = 20` not usable in the null engine?

Thanks in advance 🙏

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [May 28, 2025, 9:03pm UTC](https://forum.babylonjs.com/t/running-null-engine-on-specific-framerate/58708/2 "2025-05-28T21:03:02Z")

</div>

Hey there! The NullEngine has no access to WebGL or window or document objects.  
So it simply calls the renderLoop every 16ms 🙂

If you do not want that, you can simply skip calling runRenderLoop and instead call this when you want:

```auto
engine.beginFrame();
// This prints ~30-34
console.log(this.engine.getFps().toFixed())
    
// Render
this.scene.render(false, false);
engine.endFrame();

```

---

<div class="post-metadata">

**Author:** ![Panuchka](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/panuchka/32/12054_2.png) [@Panuchka](https://forum.babylonjs.com/u/Panuchka)\
**Post date:** [May 28, 2025, 9:20pm UTC](https://forum.babylonjs.com/t/running-null-engine-on-specific-framerate/58708/3 "2025-05-28T21:20:41Z")

</div>

Oh the `beginFrame` and `endFrame` did the trick, now I have a custom loop setup and it works! 🤩 Thanks Delta 🙂
