pmgl / microstudio

Free, open source game engine online
MIT License
921 stars 103 forks source link

Something isn't right with system.fps in lua #160

Closed Skaruts closed 2 years ago

Skaruts commented 2 years ago

This project runs very slow, but system.fps still displays ~60 fps:

microlifelua

I also have this same project in microScript, and there it displays the fps correctly.

pmgl commented 2 years ago

system.fps is a measure of how often the engine manages to call your function draw ; depending on the language engine inner workings, especially when the expected computation exceeds the allowed time slice (1/60 of a second), there can be some differences in the value you get. I am just guessing that the Lua engine works with shorter time slices and tries to give back control more often, while the microScript engine tries to not interrupt the main thread provided it doesn't exceed a few frames.

Also microScript in the browser is much faster than Lua in the browser. This is not inherent to Lua though, Lua can be extremely fast when you are using a native interpreter with LuaJIT. microScript has a big advantage in the browser because choices were made from the start to allow quick execution in JavaScript (and yet the transpiler isn't even activated in the current version!).