Created
October 15, 2023 14:08
-
-
Save andrew-wilkes/8948ede654d273dc5707110cadf157b3 to your computer and use it in GitHub Desktop.
Godot Speed Testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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