Added execution order test
This commit is contained in:
63
client/test/benchmark/Benchmark.gd
Normal file
63
client/test/benchmark/Benchmark.gd
Normal file
@ -0,0 +1,63 @@
|
||||
extends Node
|
||||
|
||||
var n := 1000000
|
||||
var benchmarks = [
|
||||
"pass",
|
||||
"get_node",
|
||||
"find_child",
|
||||
"get_child",
|
||||
"get_parent",
|
||||
"get_viewport",
|
||||
"get_tree",
|
||||
"create_timer",
|
||||
]
|
||||
|
||||
func _ready():
|
||||
for b in benchmarks:
|
||||
print("%s:" % b)
|
||||
bench(self["_%s" % b])
|
||||
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
get_tree().quit()
|
||||
|
||||
func bench(callable: Callable):
|
||||
var t := now()
|
||||
callable.call()
|
||||
prints(round((now() - t) / n * 1000000000), "ns")
|
||||
|
||||
func now() -> float:
|
||||
return Time.get_unix_time_from_system()
|
||||
|
||||
func _pass():
|
||||
for i in range(n):
|
||||
pass
|
||||
|
||||
func _get_node():
|
||||
for i in range(n):
|
||||
get_node("Child")
|
||||
|
||||
func _find_child():
|
||||
for i in range(n):
|
||||
find_child("Child")
|
||||
|
||||
func _get_child():
|
||||
for i in range(n):
|
||||
get_child(0)
|
||||
|
||||
func _get_parent():
|
||||
for i in range(n):
|
||||
get_parent()
|
||||
|
||||
func _get_viewport():
|
||||
for i in range(n):
|
||||
get_viewport()
|
||||
|
||||
func _get_tree():
|
||||
for i in range(n):
|
||||
get_tree()
|
||||
|
||||
func _create_timer():
|
||||
var tree := get_tree()
|
||||
|
||||
for i in range(n):
|
||||
tree.create_timer(0)
|
10
client/test/benchmark/Benchmark.tscn
Normal file
10
client/test/benchmark/Benchmark.tscn
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bk5p5w2gxxuq5"]
|
||||
|
||||
[ext_resource type="Script" path="res://test/benchmark/Benchmark.gd" id="1_363x2"]
|
||||
|
||||
[node name="Benchmark" type="Node"]
|
||||
|
||||
[node name="Node" type="Node" parent="."]
|
||||
script = ExtResource("1_363x2")
|
||||
|
||||
[node name="Child" type="Node" parent="Node"]
|
44
client/test/order/TestOrder.gd
Normal file
44
client/test/order/TestOrder.gd
Normal file
@ -0,0 +1,44 @@
|
||||
extends Node
|
||||
|
||||
func _init():
|
||||
callback("_init")
|
||||
|
||||
func _enter_tree():
|
||||
callback("_enter_tree")
|
||||
|
||||
func _exit_tree():
|
||||
callback("_exit_tree")
|
||||
|
||||
func _ready():
|
||||
callback("_ready")
|
||||
get_tree().process_frame.connect(callback.bind("process_frame"))
|
||||
get_tree().physics_frame.connect(callback.bind("physics_frame"))
|
||||
|
||||
func _process(_delta):
|
||||
callback("_process")
|
||||
queue_free()
|
||||
|
||||
func _physics_process(_delta):
|
||||
callback("_physics_process")
|
||||
|
||||
func _notification(what):
|
||||
match what:
|
||||
NOTIFICATION_PROCESS:
|
||||
callback("NOTIFICATION_PROCESS")
|
||||
NOTIFICATION_PHYSICS_PROCESS:
|
||||
callback("NOTIFICATION_PHYSICS_PROCESS")
|
||||
NOTIFICATION_PARENTED:
|
||||
callback("NOTIFICATION_PARENTED")
|
||||
NOTIFICATION_UNPARENTED:
|
||||
callback("NOTIFICATION_UNPARENTED")
|
||||
NOTIFICATION_PREDELETE:
|
||||
callback("NOTIFICATION_PREDELETE")
|
||||
|
||||
func _input(_event):
|
||||
callback("_input")
|
||||
|
||||
func _unhandled_input(_event):
|
||||
callback("_unhandled_input")
|
||||
|
||||
func callback(s):
|
||||
print("[%d] [%s]: %s" % [Engine.get_frames_drawn(), name, s])
|
9
client/test/order/TestOrder.tscn
Normal file
9
client/test/order/TestOrder.tscn
Normal file
@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://4cjm7vlsa7a1"]
|
||||
|
||||
[ext_resource type="Script" path="res://test/order/TestOrder.gd" id="1_d3f6g"]
|
||||
|
||||
[node name="Parent" type="Node"]
|
||||
script = ExtResource("1_d3f6g")
|
||||
|
||||
[node name="Child" type="Node" parent="."]
|
||||
script = ExtResource("1_d3f6g")
|
Reference in New Issue
Block a user