Skip to content

Commit

Permalink
add benchmark from godotengine/godot#70838
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxUserGD committed Jan 3, 2023
1 parent 10c8b23 commit 5c8c283
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/benchmark.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,44 @@ func _init() -> void:
info("string")
start_ms = Time.get_ticks_msec()
check(start_ms, string(), 300000)
info("pr")
start_ms = Time.get_ticks_msec()
check(start_ms, pr(), 6553600)
self.quit()
info("pr_typed")
start_ms = Time.get_ticks_msec()
check(start_ms, pr_typed(), 6553600)
self.quit()
return

func pr() -> int:
const elems = 6553600
var arr = []
for x in range(elems):
arr.append(randi() % elems)
var acc = 0.0
for e in arr:
var e2 = arr[e]
var e3 = arr[e2]
acc += e * e2
acc *= e3 + e
acc = sqrt(acc)
return arr.size()

func pr_typed() -> int:
const elems: int = 6553600
var arr: PackedInt32Array = []
for x in range(elems):
arr.append(randi() % elems)
var acc : float = 0.0
for e in arr:
var e2 :int = arr[e]
var e3 :int = arr[e2]
acc += e * e2
acc *= e3 + e
acc = sqrt(acc)
return arr.size()

func arr() -> int:
var array: Array = []
while array.size() < 1500:
Expand Down

0 comments on commit 5c8c283

Please sign in to comment.