Time support (#63)

This commit is contained in:
Rafał Mikrut 2021-11-01 09:40:45 +01:00 committed by GitHub
parent 95da6a1ad7
commit c4fe91f121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

1
.gitignore vendored
View File

@ -12,3 +12,4 @@ logs/
.godot/imported/
.godot/editor
shader_cache/
.import/

View File

@ -24,9 +24,18 @@ const alone_steps: Array = [
"res://AutomaticBugs/FunctionExecutor.tscn", # Only runs
]
var time_object : Object
func _init():
start_time = OS.get_ticks_msec()
if ClassDB.class_exists("_Time"):
time_object = ClassDB.instance("_Time")
elif ClassDB.class_exists("Time"):
time_object = ClassDB.instance("_Time")
else:
time_object = ClassDB.instance("_OS")
start_time = time_object.get_ticks_msec()
# In case when user doesn't provide time
time_for_each_step = time_to_show / (alone_steps.size())
@ -40,7 +49,7 @@ func _init():
func _process(delta: float) -> void:
var current_run_time: int = OS.get_ticks_msec() - start_time
var current_run_time: int = time_object.get_ticks_msec() - start_time
# While loop instead if, will allow to properly flush results under heavy operations(e.g. Thread sanitizer)
while current_run_time > time_to_print_next_time:
@ -50,3 +59,6 @@ func _process(delta: float) -> void:
if current_run_time > time_to_show && can_be_closed:
print("######################## Ending test ########################")
get_tree().quit()
func _exit_tree() -> void:
time_object.free()

View File

@ -11,11 +11,11 @@ func _ready():
Autoload.can_be_closed = false
for i in Autoload.alone_steps.size() + 1:
array_with_time_to_change.append(OS.get_ticks_msec() + i * Autoload.time_for_each_step)
array_with_time_to_change.append(Autoload.time_object.get_ticks_msec() + i * Autoload.time_for_each_step)
func _process(_delta):
if current_scene < Autoload.alone_steps.size() - 1 && OS.get_ticks_msec() > array_with_time_to_change[current_scene + 1]:
if current_scene < Autoload.alone_steps.size() - 1 && Autoload.time_object.get_ticks_msec() > array_with_time_to_change[current_scene + 1]:
current_scene += 1
if current_scene == Autoload.alone_steps.size() - 1:
Autoload.can_be_closed = true