diff --git a/tests/perf/list/icon.png b/tests/perf/list/icon.png new file mode 100644 index 0000000..39b4b01 Binary files /dev/null and b/tests/perf/list/icon.png differ diff --git a/tests/perf/list/icon.png.import b/tests/perf/list/icon.png.import new file mode 100644 index 0000000..96cbf46 --- /dev/null +++ b/tests/perf/list/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/tests/perf/list/list.gd b/tests/perf/list/list.gd new file mode 100644 index 0000000..60c81d1 --- /dev/null +++ b/tests/perf/list/list.gd @@ -0,0 +1,58 @@ +extends Node + +const ELEMENT_COUNT = 10000 + +class Profiler: + var name: String + var t1: float + var t2: float + + func start(p_name := "Profiling result"): + t1 = OS.get_ticks_msec() + name = p_name + + func stop(): + t2 = OS.get_ticks_msec() + var elapsed = t2 - t1 + print("%s: %s msec" % [name, elapsed]) + return elapsed + +var profiler = Profiler.new() + +func _ready(): + var methods = get_method_list() + var tests = [] + for m in methods: + if m.name.begins_with("test_"): + tests.push_back(m.name) + tests.sort() + for test in tests: + profiler.start(test) + call(test) + profiler.stop() + +#=============================================================================== +# Performance tests! +#=============================================================================== +func test_array_push_back(): + var array = Array() + for i in ELEMENT_COUNT: + array.push_back("Godot") + + +func test_array_push_front(): + var array = Array() + for i in ELEMENT_COUNT: + array.push_front("Godot") + + +func test_list_push_back(): + var list = LinkedList.new() + for i in ELEMENT_COUNT: + list.push_back("Goost") + + +func test_list_push_front(): + var list = LinkedList.new() + for i in ELEMENT_COUNT: + list.push_front("Goost") diff --git a/tests/perf/list/list.tscn b/tests/perf/list/list.tscn new file mode 100644 index 0000000..517237b --- /dev/null +++ b/tests/perf/list/list.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://list.gd" type="Script" id=1] + +[node name="list" type="Node"] +script = ExtResource( 1 ) diff --git a/tests/perf/list/project.godot b/tests/perf/list/project.godot new file mode 100644 index 0000000..dd3c888 --- /dev/null +++ b/tests/perf/list/project.godot @@ -0,0 +1,20 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +_global_script_classes=[ ] +_global_script_class_icons={ + +} + +[application] + +config/name="Goost Linked List Performance Tests" +run/main_scene="res://list.tscn" +config/icon="res://icon.png"