mirror of
https://github.com/godotengine/godot-benchmarks.git
synced 2026-01-05 10:10:08 +03:00
This will avoid large diffs later on. This also fixes GDScript warnings across the codebase.
25 lines
644 B
GDScript
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)
|