-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmanager.gd
More file actions
53 lines (42 loc) · 1.46 KB
/
Copy pathmanager.gd
File metadata and controls
53 lines (42 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
extends Node
func dir_contents(path: String, contents: PackedStringArray = PackedStringArray()) -> PackedStringArray:
var dir := DirAccess.open(path)
if dir:
dir.list_dir_begin()
var file_name = dir.get_next()
while file_name != "":
if dir.current_is_dir():
dir_contents(path.path_join(file_name), contents)
else:
contents.push_back(path.path_join(file_name))
file_name = dir.get_next()
else:
print("An error occurred when trying to access the path: %s" % path)
return contents
# Called when the node enters the scene tree for the first time.
func _ready():
for benchmark in dir_contents("res://benchmarks/"):
do_benchmark(load(benchmark).new())
push_error("done")
await get_tree().process_frame
get_tree().quit()
var version = Engine.get_version_info()["hash"]
var do_complexity = false
func do_benchmark(benchmark : Benchmark):
push_error(benchmark.get_name())
if do_complexity:
for n in range(10):
benchmark.count = (n + 1) * benchmark.count_base()
do_benchmark_core(benchmark)
else:
benchmark.count = 10 * benchmark.count_base()
do_benchmark_core(benchmark)
func do_benchmark_core(benchmark : Benchmark):
benchmark._setup()
var start = Time.get_ticks_msec()
var mems = OS.get_static_memory_usage()
benchmark._execute()
var end = Time.get_ticks_msec()
var meme = OS.get_static_memory_usage()
benchmark._teardown()
print("%s\t%s\t%d\t%d\t%d" % [version, benchmark.get_name(), benchmark.count, end - start, meme - mems])