Skip to content

Instantly share code, notes, and snippets.

@Gnumaru
Created October 28, 2024 17:40
Show Gist options
  • Save Gnumaru/257d578ca0cd2b6dda96a8670ac556db to your computer and use it in GitHub Desktop.
Save Gnumaru/257d578ca0cd2b6dda96a8670ac556db to your computer and use it in GitHub Desktop.
extends Node
var info: Array = []
func _ready() -> void:
add_child_test('Node')
for i in ClassDB.get_inheriters_from_class('Node'):
if not ClassDB.can_instantiate(i): continue
add_child_test(i)
info.sort_custom(func(l, r): return l.time < r.time)
for i in info: print("took %s ms to add %s nodes of type %s" % [i.time, i.quant, i.type])
breakpoint
func add_child_test(type: String, quant: int = 100)->void:
print('testing %s'%type)
var insts: Array = []
insts.resize(quant)
for i in quant: insts[i] = ClassDB.instantiate(type)
var time = Time.get_ticks_usec()
for i in insts: add_child(i)
time = Time.get_ticks_usec() - time
for i in get_children(true): remove_child(i)
var timems: float = time * 0.001
info.push_back({type=type, quant=quant, time=timems})
# took 0.372 ms to add 100 nodes of type MissingNode
# took 0.373 ms to add 100 nodes of type Timer
# took 0.373 ms to add 100 nodes of type ResourcePreloader
# took 0.418 ms to add 100 nodes of type WorldEnvironment
# took 0.434 ms to add 100 nodes of type Node
# took 0.44 ms to add 100 nodes of type Node3D
# took 0.446 ms to add 100 nodes of type AudioStreamPlayer
# took 0.46 ms to add 100 nodes of type RemoteTransform3D
# took 0.464 ms to add 100 nodes of type Path3D
# took 0.464 ms to add 100 nodes of type XRController3D
# took 0.468 ms to add 100 nodes of type Marker3D
# took 0.471 ms to add 100 nodes of type AudioListener3D
# took 0.473 ms to add 100 nodes of type PathFollow3D
# took 0.476 ms to add 100 nodes of type CollisionPolygon3D
# took 0.478 ms to add 100 nodes of type SpringArm3D
# took 0.478 ms to add 100 nodes of type OpenXRCompositionLayerEquirect
# took 0.48 ms to add 100 nodes of type XROrigin3D
# took 0.486 ms to add 100 nodes of type PhysicalBoneSimulator3D
# took 0.49 ms to add 100 nodes of type XRCamera3D
# took 0.491 ms to add 100 nodes of type SkeletonIK3D
# took 0.493 ms to add 100 nodes of type AnimationTree
# took 0.494 ms to add 100 nodes of type Camera3D
# took 0.498 ms to add 100 nodes of type OpenXRHand
# took 0.503 ms to add 100 nodes of type XRFaceModifier3D
# took 0.512 ms to add 100 nodes of type XRNode3D
# took 0.516 ms to add 100 nodes of type HTTPRequest
# took 0.517 ms to add 100 nodes of type NavigationAgent2D
# took 0.518 ms to add 100 nodes of type CollisionShape3D
# took 0.519 ms to add 100 nodes of type GridMap
# took 0.52 ms to add 100 nodes of type Decal
# took 0.528 ms to add 100 nodes of type RayCast3D
# took 0.533 ms to add 100 nodes of type MultiplayerSpawner
# took 0.533 ms to add 100 nodes of type VoxelGI
# took 0.535 ms to add 100 nodes of type ShapeCast3D
# took 0.544 ms to add 100 nodes of type OpenXRCompositionLayerCylinder
# took 0.544 ms to add 100 nodes of type LightmapGI
# took 0.548 ms to add 100 nodes of type FogVolume
# took 0.555 ms to add 100 nodes of type GPUParticlesCollisionBox3D
# took 0.557 ms to add 100 nodes of type GPUParticlesAttractorBox3D
# took 0.558 ms to add 100 nodes of type MultiMeshInstance3D
# took 0.559 ms to add 100 nodes of type ReflectionProbe
# took 0.57 ms to add 100 nodes of type GPUParticlesCollisionSphere3D
# took 0.573 ms to add 100 nodes of type OccluderInstance3D
# took 0.573 ms to add 100 nodes of type GPUParticlesCollisionSDF3D
# took 0.574 ms to add 100 nodes of type MeshInstance3D
# took 0.576 ms to add 100 nodes of type GPUParticlesCollisionHeightField3D
# took 0.582 ms to add 100 nodes of type OpenXRCompositionLayerQuad
# took 0.586 ms to add 100 nodes of type RigidBody3D
# took 0.589 ms to add 100 nodes of type XRAnchor3D
# took 0.593 ms to add 100 nodes of type NavigationAgent3D
# took 0.594 ms to add 100 nodes of type SkeletonModifier3D
# took 0.594 ms to add 100 nodes of type AudioStreamPlayer3D
# took 0.595 ms to add 100 nodes of type ShaderGlobalsOverride
# took 0.598 ms to add 100 nodes of type OmniLight3D
# took 0.598 ms to add 100 nodes of type CharacterBody3D
# took 0.605 ms to add 100 nodes of type SpotLight3D
# took 0.609 ms to add 100 nodes of type Area3D
# took 0.626 ms to add 100 nodes of type VisualInstance3D
# took 0.638 ms to add 100 nodes of type NavigationObstacle3D
# took 0.639 ms to add 100 nodes of type VehicleWheel3D
# took 0.64 ms to add 100 nodes of type AnimatedSprite3D
# took 0.652 ms to add 100 nodes of type DirectionalLight3D
# took 0.653 ms to add 100 nodes of type BoneAttachment3D
# took 0.655 ms to add 100 nodes of type GeometryInstance3D
# took 0.658 ms to add 100 nodes of type NavigationRegion3D
# took 0.661 ms to add 100 nodes of type VisibleOnScreenEnabler3D
# took 0.676 ms to add 100 nodes of type CSGCombiner3D
# took 0.677 ms to add 100 nodes of type GPUParticlesAttractorSphere3D
# took 0.68 ms to add 100 nodes of type CSGTorus3D
# took 0.689 ms to add 100 nodes of type VehicleBody3D
# took 0.692 ms to add 100 nodes of type ImporterMeshInstance3D
# took 0.698 ms to add 100 nodes of type PhysicalBone3D
# took 0.701 ms to add 100 nodes of type GPUParticles3D
# took 0.707 ms to add 100 nodes of type GPUParticlesAttractorVectorField3D
# took 0.718 ms to add 100 nodes of type CSGMesh3D
# took 0.719 ms to add 100 nodes of type NavigationLink3D
# took 0.719 ms to add 100 nodes of type CSGPolygon3D
# took 0.738 ms to add 100 nodes of type CSGCylinder3D
# took 0.741 ms to add 100 nodes of type RootMotionView
# took 0.751 ms to add 100 nodes of type VisibleOnScreenNotifier3D
# took 0.766 ms to add 100 nodes of type CSGSphere3D
# took 0.779 ms to add 100 nodes of type LightmapProbe
# took 0.794 ms to add 100 nodes of type AnimationPlayer
# took 0.819 ms to add 100 nodes of type SoftBody3D
# took 0.855 ms to add 100 nodes of type StaticBody3D
# took 0.894 ms to add 100 nodes of type Sprite3D
# took 0.936 ms to add 100 nodes of type CanvasLayer
# took 0.958 ms to add 100 nodes of type CSGBox3D
# took 0.994 ms to add 100 nodes of type Marker2D
# took 0.995 ms to add 100 nodes of type Sprite2D
# took 0.998 ms to add 100 nodes of type Line2D
# took 1.008 ms to add 100 nodes of type CollisionPolygon2D
# took 1.01 ms to add 100 nodes of type Node2D
# took 1.013 ms to add 100 nodes of type XRHandModifier3D
# took 1.041 ms to add 100 nodes of type RemoteTransform2D
# took 1.042 ms to add 100 nodes of type RayCast2D
# took 1.05 ms to add 100 nodes of type AudioListener2D
# took 1.059 ms to add 100 nodes of type CollisionShape2D
# took 1.061 ms to add 100 nodes of type XRBodyModifier3D
# took 1.069 ms to add 100 nodes of type ShapeCast2D
# took 1.078 ms to add 100 nodes of type PathFollow2D
# took 1.081 ms to add 100 nodes of type CPUParticles2D
# took 1.092 ms to add 100 nodes of type CPUParticles3D
# took 1.094 ms to add 100 nodes of type SubViewport
# took 1.095 ms to add 100 nodes of type Path2D
# took 1.098 ms to add 100 nodes of type MeshInstance2D
# took 1.099 ms to add 100 nodes of type Skeleton2D
# took 1.111 ms to add 100 nodes of type VisibleOnScreenEnabler2D
# took 1.12 ms to add 100 nodes of type BackBufferCopy
# took 1.123 ms to add 100 nodes of type VisibleOnScreenNotifier2D
# took 1.126 ms to add 100 nodes of type Polygon2D
# took 1.134 ms to add 100 nodes of type DirectionalLight2D
# took 1.136 ms to add 100 nodes of type AnimatedSprite2D
# took 1.138 ms to add 100 nodes of type PointLight2D
# took 1.157 ms to add 100 nodes of type CharacterBody2D
# took 1.168 ms to add 100 nodes of type CanvasGroup
# took 1.19 ms to add 100 nodes of type PhysicalBone2D
# took 1.223 ms to add 100 nodes of type MultiMeshInstance2D
# took 1.227 ms to add 100 nodes of type TileMapLayer
# took 1.24 ms to add 100 nodes of type MultiplayerSynchronizer
# took 1.261 ms to add 100 nodes of type StaticBody2D
# took 1.263 ms to add 100 nodes of type CanvasModulate
# took 1.27 ms to add 100 nodes of type ParallaxBackground
# took 1.277 ms to add 100 nodes of type TouchScreenButton
# took 1.289 ms to add 100 nodes of type Parallax2D
# took 1.297 ms to add 100 nodes of type ParallaxLayer
# took 1.312 ms to add 100 nodes of type AnimatableBody2D
# took 1.319 ms to add 100 nodes of type AudioStreamPlayer2D
# took 1.32 ms to add 100 nodes of type AnimatableBody3D
# took 1.331 ms to add 100 nodes of type NavigationRegion2D
# took 1.352 ms to add 100 nodes of type Area2D
# took 1.396 ms to add 100 nodes of type RigidBody2D
# took 1.446 ms to add 100 nodes of type NavigationObstacle2D
# took 1.553 ms to add 100 nodes of type Camera2D
# took 1.566 ms to add 100 nodes of type NavigationLink2D
# took 1.6 ms to add 100 nodes of type LightOccluder2D
# took 1.902 ms to add 100 nodes of type GPUParticles2D
# took 1.994 ms to add 100 nodes of type Skeleton3D
# took 2.423 ms to add 100 nodes of type ReferenceRect
# took 2.443 ms to add 100 nodes of type BaseButton
# took 2.495 ms to add 100 nodes of type TextureRect
# took 2.502 ms to add 100 nodes of type TextureButton
# took 2.54 ms to add 100 nodes of type HingeJoint3D
# took 2.543 ms to add 100 nodes of type NinePatchRect
# took 2.579 ms to add 100 nodes of type Generic6DOFJoint3D
# took 2.603 ms to add 100 nodes of type TextureProgressBar
# took 2.623 ms to add 100 nodes of type PinJoint3D
# took 2.632 ms to add 100 nodes of type Control
# took 2.641 ms to add 100 nodes of type ConeTwistJoint3D
# took 2.752 ms to add 100 nodes of type VideoStreamPlayer
# took 2.788 ms to add 100 nodes of type AspectRatioContainer
# took 2.859 ms to add 100 nodes of type TileMap
# took 2.892 ms to add 100 nodes of type ColorRect
# took 2.933 ms to add 100 nodes of type CenterContainer
# took 3.108 ms to add 100 nodes of type SliderJoint3D
# took 3.169 ms to add 100 nodes of type Range
# took 3.233 ms to add 100 nodes of type PinJoint2D
# took 3.255 ms to add 100 nodes of type GrooveJoint2D
# took 3.422 ms to add 100 nodes of type SubViewportContainer
# took 3.437 ms to add 100 nodes of type DampedSpringJoint2D
# took 3.554 ms to add 100 nodes of type Panel
# took 3.574 ms to add 100 nodes of type Container
# took 3.819 ms to add 100 nodes of type BoxContainer
# took 3.94 ms to add 100 nodes of type GraphElement
# took 4.055 ms to add 100 nodes of type VBoxContainer
# took 4.1 ms to add 100 nodes of type PanelContainer
# took 4.118 ms to add 100 nodes of type Label3D
# took 4.277 ms to add 100 nodes of type HBoxContainer
# took 4.574 ms to add 100 nodes of type GridContainer
# took 4.784 ms to add 100 nodes of type HSeparator
# took 4.836 ms to add 100 nodes of type VFlowContainer
# took 4.919 ms to add 100 nodes of type VSeparator
# took 4.952 ms to add 100 nodes of type FlowContainer
# took 5.551 ms to add 100 nodes of type HFlowContainer
# took 6.486 ms to add 100 nodes of type MarginContainer
# took 12.001 ms to add 100 nodes of type VSplitContainer
# took 12.269 ms to add 100 nodes of type HSplitContainer
# took 12.441 ms to add 100 nodes of type VSlider
# took 12.692 ms to add 100 nodes of type SplitContainer
# took 13.63 ms to add 100 nodes of type HSlider
# took 14.38 ms to add 100 nodes of type VScrollBar
# took 14.591 ms to add 100 nodes of type HScrollBar
# took 17.206 ms to add 100 nodes of type Popup
# took 18.372 ms to add 100 nodes of type LinkButton
# took 20.51 ms to add 100 nodes of type Label
# took 22.781 ms to add 100 nodes of type MenuBar
# took 23.372 ms to add 100 nodes of type LineEdit
# took 23.944 ms to add 100 nodes of type TabBar
# took 25.82 ms to add 100 nodes of type PopupPanel
# took 31.272 ms to add 100 nodes of type ProgressBar
# took 34.273 ms to add 100 nodes of type ScrollContainer
# took 34.844 ms to add 100 nodes of type ItemList
# took 36.636 ms to add 100 nodes of type GraphNode
# took 38.825 ms to add 100 nodes of type GraphFrame
# took 39.169 ms to add 100 nodes of type Button
# took 42.869 ms to add 100 nodes of type SpinBox
# took 44.595 ms to add 100 nodes of type ColorPickerButton
# took 47.055 ms to add 100 nodes of type RichTextLabel
# took 50.493 ms to add 100 nodes of type CheckBox
# took 51.241 ms to add 100 nodes of type CheckButton
# took 52.231 ms to add 100 nodes of type TabContainer
# took 65.129 ms to add 100 nodes of type Bone2D
# took 83.15 ms to add 100 nodes of type TextEdit
# took 90.043 ms to add 100 nodes of type PopupMenu
# took 109.428 ms to add 100 nodes of type AcceptDialog
# took 109.499 ms to add 100 nodes of type CodeEdit
# took 131.484 ms to add 100 nodes of type MenuButton
# took 137.471 ms to add 100 nodes of type OptionButton
# took 164.344 ms to add 100 nodes of type ConfirmationDialog
# took 187.51 ms to add 100 nodes of type Window
# took 322.43 ms to add 100 nodes of type Tree
# took 446.817 ms to add 100 nodes of type GraphEdit
# took 516.929 ms to add 100 nodes of type StatusIndicator
# took 1315.819 ms to add 100 nodes of type ColorPicker
# took 1963.032 ms to add 100 nodes of type FileDialog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment