Godot 4.3 Performance: C++ vs. C# vs. GDScript

Поделиться
HTML-код
  • Опубликовано: 17 ноя 2024

Комментарии • 23

  • @igork1336
    @igork1336 Месяц назад +1

    I use GDScript to design and test the Architecture (or build a prototype). Once I'm satisfied with the result, I convert it to C++. GDScript performs well, and for most developers, it makes only sense to do a C++ conversion if you are creating something computationally heavy, for example, AI that will be used by over 1000 NPCs so they can interact with each other.

    • @AntzGames
      @AntzGames  Месяц назад +1

      That is where I am at. I plan to use it only for very expensive tasks. I went threw this exercise to learn how to do C++ GDExtensions. It is good to know I have options in Godot once you hit performance limitations.

  • @AntzGames
    @AntzGames  2 месяца назад +9

    Keep in mind that this is very specific example, and that GDScript actually performs well in real world examples. C++ GDExtension calls are expensive and if you have many calls per frame/per node the performance gains using C++ via extensions becomes less.

    • @JustVoylin
      @JustVoylin 2 месяца назад +1

      Also, GDExtensions are a pain to work with and troubleshoot, don't forget about that part. Made a GDExtension for video playback in Godot, GoZen GDE, and it was/is a nightmare XD

    • @AntzGames
      @AntzGames  2 месяца назад +1

      @@JustVoylin I agree. It took me 2 hours to setup my C++ GDExtensions environment for the 1st time. That being said, its good to know I can code a very expensive algorithm in C++ as an extension if needed now.

  • @charles_kuperus
    @charles_kuperus Месяц назад

    yes please do a rust version of this Video.

  • @kewnst
    @kewnst 2 месяца назад +2

    gicven how much gd script borrows from python idl ike to see python vs godot test.

    • @AntzGames
      @AntzGames  2 месяца назад

      So this prime number test is like the worst possible test for GDScript (and most likely Python). I used it specifically to expose the weakness of GDScript in code loops. I would take the results with a grain of salt. GDScript actually does pretty well in real world rendering examples.
      The official Godot benchmarks can be run here: github.com/godotengine/godot-benchmarks

  • @everythingcouldbesimplify818
    @everythingcouldbesimplify818 Месяц назад

    I wonder if this test is comparing stack in C++ with heap in the C#, and C# in the editor without the released build, cause I tried it and got 3ms in the release build and around 12-16ms in the editor.

    • @AntzGames
      @AntzGames  Месяц назад

      To add some context to your original comment and also this edited comment.
      So this algorithm is very bad in terms of space, and yes, 2 million is very big stack, even for C++.
      Time Complexity: O(N*log(log(N)))
      Auxiliary Space: O(N)
      I may redo the test using the test using the Segmented-Sieve algorithm: www.geeksforgeeks.org/segmented-sieve/
      Which reduces the space needed for the algo to the square root of 2million (which is only 1414), shown below:
      Time Complexity : O(n * ln(sqrt(n)))
      Auxiliary Space: O(sqrt(n))
      Also, I should also redo the tests using the release build as you suggested. Also I may add both Rust and Java/Kotlin GDExtension times, as many people have requested it.

  • @Ivorforce
    @Ivorforce Месяц назад

    Hiya, interesting comparison! I'm currently working on a numpy-like math API and came across this, so I wanted to have a go at this myself. My 2c, I'd be surprised if GDScript was actually 100x slower than c++, or 27x slower than C#, in the real world. C# may have some edge by being JIT'd and its the compiler having a better implementation than GDScript, but it's also possible the compilers even vectorized your calls automatically, elevating their speeds beyond what's expected from the benchmark designer. But it's hard to say what really happened without actually opening the guts of the binaries. Benchmarks are hard!
    Anyway, my gdscript implementation got comparable results to yours (about 160ms), while it took about 9ms with the vectorized calls (~16x decrease). That doesn't quite bring it to C# or C++ levels according to your test, but it brings it a lot closer! The library (NumDot) does use SIMD vectorization to speed up assignments, but it's somewhat handicapped in comparison to C++ plain because of the many abstraction layers between logic and assignment.

    • @AntzGames
      @AntzGames  Месяц назад +1

      In a real world game example with a complex scene graph, GDScript performs much better, and many C++ GDExtension calls becomes more expensive. However, a highly computational and/or any algo that requires loops severely impacts GDScript.
      Also I think you might want to edit your statement >>> I'd be surprised if C# was actually 100x slower than c++, or 27x slower than C#
      I know you meant GDScript at the beginning.

    • @Ivorforce
      @Ivorforce Месяц назад

      @@AntzGames you got it right, i meant GDscript there :) statement is edited.

  • @katm9877
    @katm9877 Месяц назад

    I thought GDExtension did not work with HTML5 target? How do you have c++/html5 results?

    • @AntzGames
      @AntzGames  Месяц назад

      C++ GDExtensions can be compiled using Emscription to produce a Web Assembly module (WASM) and run on the web, as I explain in the video. This is done automatically on export.
      Here is another example: www.reddit.com/r/godot/comments/1atvz4z/gdextensionc_game_on_the_web_with_wasm_sand_slide/

    • @AntzGames
      @AntzGames  Месяц назад

      So I added a GitHub repository so you can run the GDExtension on an HTML export yourself: github.com/antzGames/GDExtensions_VS_GDScript_Test

  • @gameprogramming6550
    @gameprogramming6550 2 месяца назад

    Benchmark Java with Godot

    • @AntzGames
      @AntzGames  2 месяца назад +1

      Check out: ruclips.net/video/oiuECV23lP0/видео.html for benchmarks of using Java with Godot. It is basically at C++ speeds.

  • @ghorshy
    @ghorshy Месяц назад

    What version of .NET were you using in these tests?

    • @AntzGames
      @AntzGames  Месяц назад

      Hello. V8.0.303
      C:\Users\antho>dotnet --list-sdks
      8.0.303 [C:\Program Files\dotnet\sdk]

  • @AntzGames
    @AntzGames  Месяц назад

    Please see my updated video: ruclips.net/video/qDXomV7Ojko/видео.html

  • @fireball7708
    @fireball7708 Месяц назад

    Rust + godot ?

    • @AntzGames
      @AntzGames  Месяц назад

      So this older Godot3 repo did some rust + GDNative (which is now GDExtensions): github.com/extrawurst/godot-rust-benchmark
      I would assume a rust shared library GDExtension to be relatively the same speed as a shared library C++ GDExtension.