Added more benchmarks
This commit is contained in:
parent
fcee55d9a4
commit
19c1d3e74c
@ -1,6 +1,7 @@
|
|||||||
extends Node
|
extends Node3D
|
||||||
|
|
||||||
var n := 1000000
|
var n := 1000000
|
||||||
|
var pass_time := 0.0
|
||||||
var benchmarks = [
|
var benchmarks = [
|
||||||
"pass",
|
"pass",
|
||||||
"get_node",
|
"get_node",
|
||||||
@ -9,6 +10,11 @@ var benchmarks = [
|
|||||||
"get_parent",
|
"get_parent",
|
||||||
"get_viewport",
|
"get_viewport",
|
||||||
"get_tree",
|
"get_tree",
|
||||||
|
"get_ticks_msec",
|
||||||
|
"get_ticks_usec",
|
||||||
|
"get_unix_time_from_system",
|
||||||
|
"get_world_3d",
|
||||||
|
"script_func_call",
|
||||||
"create_timer",
|
"create_timer",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -21,12 +27,9 @@ func _ready():
|
|||||||
get_tree().quit()
|
get_tree().quit()
|
||||||
|
|
||||||
func bench(callable: Callable):
|
func bench(callable: Callable):
|
||||||
var t := now()
|
var t := Time.get_unix_time_from_system()
|
||||||
callable.call()
|
callable.call()
|
||||||
prints(round((now() - t) / n * 1000000000), "ns")
|
prints(round((Time.get_unix_time_from_system() - t) / n * 1000000000), "ns")
|
||||||
|
|
||||||
func now() -> float:
|
|
||||||
return Time.get_unix_time_from_system()
|
|
||||||
|
|
||||||
func _pass():
|
func _pass():
|
||||||
for i in range(n):
|
for i in range(n):
|
||||||
@ -56,8 +59,31 @@ func _get_tree():
|
|||||||
for i in range(n):
|
for i in range(n):
|
||||||
get_tree()
|
get_tree()
|
||||||
|
|
||||||
|
func _get_ticks_msec():
|
||||||
|
for i in range(n):
|
||||||
|
Time.get_ticks_msec()
|
||||||
|
|
||||||
|
func _get_ticks_usec():
|
||||||
|
for i in range(n):
|
||||||
|
Time.get_ticks_usec()
|
||||||
|
|
||||||
|
func _get_unix_time_from_system():
|
||||||
|
for i in range(n):
|
||||||
|
Time.get_unix_time_from_system()
|
||||||
|
|
||||||
|
func _get_world_3d():
|
||||||
|
for i in range(n):
|
||||||
|
get_world_3d()
|
||||||
|
|
||||||
|
func _script_func_call():
|
||||||
|
for i in range(n):
|
||||||
|
empty()
|
||||||
|
|
||||||
func _create_timer():
|
func _create_timer():
|
||||||
var tree := get_tree()
|
var tree := get_tree()
|
||||||
|
|
||||||
for i in range(n):
|
for i in range(n):
|
||||||
tree.create_timer(0)
|
tree.create_timer(0)
|
||||||
|
|
||||||
|
func empty():
|
||||||
|
pass
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
[node name="Benchmark" type="Node"]
|
[node name="Benchmark" type="Node"]
|
||||||
|
|
||||||
[node name="Node" type="Node" parent="."]
|
[node name="Node" type="Node3D" parent="."]
|
||||||
script = ExtResource("1_363x2")
|
script = ExtResource("1_363x2")
|
||||||
|
|
||||||
[node name="Child" type="Node" parent="Node"]
|
[node name="Child" type="Node" parent="Node"]
|
||||||
|
Loading…
Reference in New Issue
Block a user