Replies: 1 comment 3 replies
-
|
Hey @Denneisk, nice initiative, thanks for bringing this up! Beware that this optimization you made of using a script local One interesting variant implementation would be one using an |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It was bound to be asked eventually...
Warning
This is NOT a comprehensive benchmark, just a quick little aside for my curiosity.
Everyone knows Lua has a claim to fame for its speed, especially with LuaJIT. This project doesn't use LuaJIT (yet), but I'm still curious, how does its speed fare compared to GDScript? Well, to test this, I went to see if there were any public benchmarks for GDScript that I could use. I chose csharp-gd-inventory-test because it was the first option available and seemed good enough for a quick test. I avoided going for the official Godot benchmarks because those are very in-depth and I didn't really want to get into those weeds right now.
My goal with this code was to simply translate the GDScript code to Lua nearly verbatim, and then optimize that verbatim copy with Lua idioms and speed tricks. The results were pretty nice. On average, optimized Lua performed around 3x faster than GDScript. In a worst case, unoptimized Lua (a verbatim copy of GDScript) runs at least 6x worse here. Another interesting thing is that Lua by itself has some really good cold loop performance, beating C# in these tests on single runs. Whether or not that's coincidence is up to you to decide.
You can see the code I used at this repo. I won't be updating the README to include my results (since I'm lazy), but here's some copy/paste from my own test runs. This was done with an exported project to be as accurate as possible.
This was tested on Godot 4.4.1 on Windows x86_64, with the latest (as of writing) commit of Lua GDExtension 384dc96.
Results
I'd love to see what LuaJIT could do here.
Beta Was this translation helpful? Give feedback.
All reactions