Skip to content

Instantly share code, notes, and snippets.

@andrew-wilkes
Created October 15, 2023 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrew-wilkes/8948ede654d273dc5707110cadf157b3 to your computer and use it in GitHub Desktop.
Save andrew-wilkes/8948ede654d273dc5707110cadf157b3 to your computer and use it in GitHub Desktop.
Godot Speed Testing
extends Control
# Code to flip between 0 and 1 speed comparisons
func _ready():
const MILLION = 1_000_000
var start = Time.get_ticks_msec()
var x = 1
for n in MILLION:
x = (x + 1) % 2
print(Time.get_ticks_msec() - start)
start = Time.get_ticks_msec()
for n in MILLION:
x = int(x == 0)
print(Time.get_ticks_msec() - start)
var v = [1, 0]
start = Time.get_ticks_msec()
for n in MILLION:
x = v[x]
print(Time.get_ticks_msec() - start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment