-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic performance tests for linked list
Made out of curiosity. See godotengine/godot-proposals#1522.
- Loading branch information
Showing
5 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |