I benchmarked Godot! C# vs GDScript

preview_player
Показать описание
As a Unity refugee, I've just taken shelter in Godot, and the burning question on my mind is which scripting language should I choose? C# or GDScript? Which one has better performance? So I take this as a learning opportunity and built a test bench on Godot, and hence this video.

Update:
Note: C# on Godot 4.0/4.1 doesn't work on Android, iOS and web. To use C# on those platforms you'll have to use Godot 3. Good news is that C# support for Android is on 4.2 which should be released in November. You can use the pre-release 4.2 if you really want to use C# on Godot 4 for Android.

As some suggested, I've also try run the Unity test again with IL2CPP. There's a 50% performance increase, reaching around 300fps. Still a bit behind Godot but the performance difference is now more reasonable. However, do note that most Unity devs are building their games in mono. Took me like an hour to install more than 10GB of C++ and visual studio stuffs to compile it in IL2CPP.
Рекомендации по теме
Комментарии
Автор

Remember: performance depends on use case. If this is racing, C# would be an F1 car, GDScript would be an F2 car, but the race is for go-karts (your game project is too small for language performance to matter). So design and make a fun game first, optimize second.

OmegaF
Автор

Note: C# on Godot 4.0/4.1 doesn't work on Android, iOS and web. To use C# on those platforms you'll have to use Godot 3. Good news is that C# support for Android is on 4.2 which should be released in November. You can use the pre-release 4.2 if you really want to use C# on Godot 4 for Android.
As some suggested, I've also try run the Unity test again with IL2CPP. There's a 50% performance increase, reaching around 300fps. Still a bit behind Godot but the performance difference is now more reasonable. However, do note that most Unity devs are building their games in mono. Took me like an hour to install more than 10GB of C++ and visual studio stuffs to compile it in IL2CPP.

boonmakesgames
Автор

A bigger disclaimer that this is for people coming from Unity (or more generally with C# background) would be nice. You probably get even better performance with things such as C/C++/Rust. At least Rust is also a supported scripting language for Godot (EDIT: Looking it up, Rust is actually the one that is just unofficially supported. C/C++ has official scripting support).

SMTM
Автор

The beauty though is you can use both or even C++. If you have a bottleneck just write that part in C# or C++ and move on.

DEATHTRUTH
Автор

A grain of salt to anyone watching this.
1. Make it work
2. Benchmark it
3. If the benchmarks hit the target, that's good enough else
4. Find the bottleneck and fix it, go back to step 2.

ImmacHn
Автор

GDScript felt pretty nice once I wrapped my head around it. Was able to get a project going in a couple of days. And as long as framerate is about 60fps, it's all good.

jmanners
Автор

nice, more reason to use c# than GD script.
For me, c# is better at taking advantage of auto-complete, which makes coding very fast.

edward
Автор

Really good video! I wanted to see something like this for a while.

neuplop
Автор

This is much needed. Looking forward to benchmarks for rendering, physics etc.

arabhuzaifa
Автор

Just to avoid people being misinformed by the comments about engine calls being slow and the "Godot is not the new Unity" blog:
This is incorrect information, as Godot's founder Juan linietsky explained the vast majority of engine calls are super fast and only the parts that are still being worked on like the one that user found are slower until they are finished. He also opened a proposal fixing the problem. Even the writter of that blog was very happy to know about all that.
When GDScript and C# have the same speed here it is not because both are being slowed down, but because in both cases the heavy lifting is being done by Godot in C++ and not by GDScript or C#, in other words: both are being extremely fast.

AlvaroLand
Автор

I don't know the inner workings of Godot, but I have to assume that the differences are the fault of the compiler and not the language used directly.

atomicus
Автор

The main drawback of C# as I see it is the GC, which is what makes GDScript attractive. It would be interesting to see a real world longer running game loop benchmark to illustrate the effects of GC pauses, as that is certainly something that is a common complaint with C# in Unity.

sdether
Автор

I recently moved my project from Unity to Godot and am experiencing a 2X to 3X performance improvement over unity even though I rewrote all my scripts in Gdscript to give it a try.
So C# may be faster than Gdscript, but (at least in my experience so far) Godot with gdscript is way faster than Unity with C#
Something to consider for those switching engines like me.
Not tried if godot with C# is even faster...

shaunjansa
Автор

More Benchmarks Please. I would be especially interested in 3D Performance or even more specifically the Performance on Standalone VR Headsets using all the performance features like Fixed Foveated Rendering or Multiview Rendering. I would love to switch to Godot, but performance budgets are so tight on these Headsets that i am unsure if godot can be competitive here.

DonC
Автор

Its nice if you have certain functionality taking too long just re-write that part in C# or CPP, it allows mix and match

draftingish
Автор

A big part of why C# code runs faster in Godot is simply that Godot is using a modern .NET runtime under the hood.

Godot 4.0 introduced .NET 6, which is the current long-term support version of .NET. That means you get all of the performance improvements that are inherent to that build of .NET. Unity does _not_ use a modern .NET implementation, and it shows both in the fact that you have to use older versions of the C# language, and in the performance difference you see.

buxt-tech
Автор

amazing benchmark mate keep the great job!

pwhv
Автор

The reason your first test is on par with GDScript is because it relies mostly on engine calls which are extremely slow from either language. For the same reason you also managed to make a faster implementation of A* by not having to jump between C# and C++ calls.

For a more detailed explanation check out "Godot is not the new Unity - The anatomy of a Godot API call"

shoq
Автор

As a (non-game related) C# dev, I can't resist that sexy C# syntax. It's just so much more beautiful and readable than GDscript (lol).
From my POV, and correct me if I'm wrong, the main advantage of GDscript is that it is an interpreted language, and thus doesn't have to be compiled. So you could theoretically change your code on the fly while the game is running in debug mode, and quickly iterate. Meanwhile, with C#, you'd have to stop the process and recompile each time before testing a change to your code.
This is actually amazing for quick prototyping.

Homiloko
Автор

Yes I do think just like others that it is worth it to mention C++ scriptability of godot for perf reasons. Like I honestly prefer goind GDScript for everything and C++ for performance - but rarely if ever the latter happens in real life, just when it does its probably better than doing C# and Godot makes C++ scripting possible while in unity the C++ native codes seem much harder on API than in here.

uvata