/gds-syntax-benchmark

Speed comparisons of various syntax alternatives within the GDScript language (Godot game engine)

Primary LanguageGDScriptThe UnlicenseUnlicense

GDScript Syntax Benchmarks

Speed comparisons of various syntax alternatives within the GDScript language (Godot game engine). All code is within benchmarks.gd, including funcs referenced in results table.

SEE THE END OF THIS README FOR THE RESULTS TABLE

To Run Tests Yourself

  • Open the project in Godot
  • Click the lone node in the Scene/Node panel
  • Click the unchecked box in the Inspector for the exported variable 'Click To Run'
  • Wait several seconds for the tests to run (Godot editor may appear frozen during this time)

The script is a 'tool' and clicking this exported variable will trigger a setget function which actually runs the tests. The results will be printed in the standard output and written to your disk as README.md (clobbering the existing README.md)

Contributors

Please only add benchmarks.gd to your commits. This entire readme file is automaticaly generated by the script, so please do not commit changes to the readme itself. Thanks!

Results

Godot version: 3.1-stable (official)

    array_index  ***  49% faster than ***  array_append    (0.246 vs 0.367 sec)
      array_len  ***   4% faster than ***  array_size      (0.229 vs 0.237 sec)
    array_izero  ***  16% faster than ***  array_front     (0.207 vs 0.241 sec)
     array_ineg  ***  10% faster than ***  array_back      (0.212 vs 0.233 sec)
       var_func  ***   7% faster than ***  var_script      (0.170 vs 0.182 sec)
     var_script  ***  29% faster than ***  var_self        (0.189 vs 0.244 sec)
   iter_for_int  ***  26% faster than ***  iter_for_range  (0.334 vs 0.422 sec)
       iter_for  *** 121% faster than ***  iter_while      (0.114 vs 0.252 sec)
            ifs  ***  21% faster than ***  matches         (0.446 vs 0.537 sec)
 array_appendrw  ***   7% faster than ***  parray_appendrw (0.720 vs 0.772 sec)
   dontcallfunc  *** 227% faster than ***  callfunc        (0.115 vs 0.375 sec)
   inteval_auto  ***  58% faster than ***  inteval         (0.158 vs 0.249 sec)
 arrayeval_auto  *** 221% faster than ***  arrayeval       (0.162 vs 0.520 sec)
  dicteval_auto  *** 220% faster than ***  dicteval        (0.157 vs 0.501 sec)
  nulleval_auto  ***  54% faster than ***  nulleval        (0.155 vs 0.239 sec)