diff --git a/client/test/benchmark/Benchmark.gd b/client/test/benchmark/Benchmark.gd index e42ed6c..c87330b 100644 --- a/client/test/benchmark/Benchmark.gd +++ b/client/test/benchmark/Benchmark.gd @@ -1,6 +1,7 @@ -extends Node +extends Node3D var n := 1000000 +var pass_time := 0.0 var benchmarks = [ "pass", "get_node", @@ -9,6 +10,11 @@ var benchmarks = [ "get_parent", "get_viewport", "get_tree", + "get_ticks_msec", + "get_ticks_usec", + "get_unix_time_from_system", + "get_world_3d", + "script_func_call", "create_timer", ] @@ -21,12 +27,9 @@ func _ready(): get_tree().quit() func bench(callable: Callable): - var t := now() + var t := Time.get_unix_time_from_system() callable.call() - prints(round((now() - t) / n * 1000000000), "ns") - -func now() -> float: - return Time.get_unix_time_from_system() + prints(round((Time.get_unix_time_from_system() - t) / n * 1000000000), "ns") func _pass(): for i in range(n): @@ -56,8 +59,31 @@ func _get_tree(): for i in range(n): 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(): var tree := get_tree() for i in range(n): - tree.create_timer(0) \ No newline at end of file + tree.create_timer(0) + +func empty(): + pass \ No newline at end of file diff --git a/client/test/benchmark/Benchmark.tscn b/client/test/benchmark/Benchmark.tscn index 4e5e5c6..154bb2d 100644 --- a/client/test/benchmark/Benchmark.tscn +++ b/client/test/benchmark/Benchmark.tscn @@ -4,7 +4,7 @@ [node name="Benchmark" type="Node"] -[node name="Node" type="Node" parent="."] +[node name="Node" type="Node3D" parent="."] script = ExtResource("1_363x2") [node name="Child" type="Node" parent="Node"]