Files
godot-benchmarks/benchmarks/scene_nodes/move_children.gd
Hugo Locurcio 34a1c24f95 Resave all scenes and scripts on Godot 4.4.dev5, fix GDScript warnings
This will avoid large diffs later on.

This also fixes GDScript warnings across the codebase.
2024-11-27 15:00:18 +01:00

25 lines
644 B
GDScript

extends Benchmark
# Moving children is much slower than other scene node operations,
# so perform fewer iterations to ensure it completes in a reasonable amount of time.
const ITERATIONS = 1_000
var root: Node
var children: Array[Node]
# Benchmark move_child by moving to random positions ITERATIONS
# children ITERATIONS times. The tree is created in init.
func _init() -> void:
root = Node.new()
for i in ITERATIONS:
root.add_child(Node.new())
children = root.get_children()
func benchmark_move_children() -> void:
var size := children.size()
for node in children:
for i in ITERATIONS:
root.move_child(node, randi() % size)