mirror of
https://github.com/Relintai/regression-test-project.git
synced 2024-12-25 14:07:21 +01:00
Add time singleton (#51)
This commit is contained in:
parent
94048a0c8f
commit
a076ba07be
@ -13,6 +13,7 @@ var time_to_show: int = 25 * 1000 # How long test works in miliseconds
|
|||||||
var time_for_each_step : int = -1
|
var time_for_each_step : int = -1
|
||||||
|
|
||||||
var os
|
var os
|
||||||
|
var time
|
||||||
|
|
||||||
# Each scene runs alone
|
# Each scene runs alone
|
||||||
const alone_steps : Array = [
|
const alone_steps : Array = [
|
||||||
@ -29,7 +30,14 @@ func _init():
|
|||||||
else:
|
else:
|
||||||
os = ClassDB.instance("_Platform")
|
os = ClassDB.instance("_Platform")
|
||||||
|
|
||||||
start_time = os.get_ticks_msec()
|
if ClassDB.class_exists("Time"):
|
||||||
|
time = ClassDB.instance("Time")
|
||||||
|
elif ClassDB.class_exists("_OS"):
|
||||||
|
time = ClassDB.instance("_OS")
|
||||||
|
else:
|
||||||
|
time = ClassDB.instance("_Platform")
|
||||||
|
|
||||||
|
start_time = time.get_ticks_msec()
|
||||||
|
|
||||||
# In case when user doesn't provide time
|
# In case when user doesn't provide time
|
||||||
time_for_each_step = time_to_show / (alone_steps.size())
|
time_for_each_step = time_to_show / (alone_steps.size())
|
||||||
@ -43,7 +51,7 @@ func _init():
|
|||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
var current_run_time : int = os.get_ticks_msec() - start_time
|
var current_run_time : int = time.get_ticks_msec() - start_time
|
||||||
|
|
||||||
# While loop instead if, will allow to properly flush results under heavy operations(e.g. Thread sanitizer)
|
# 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:
|
while current_run_time > time_to_print_next_time:
|
||||||
@ -56,3 +64,6 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
func _exit_tree():
|
func _exit_tree():
|
||||||
os.free()
|
os.free()
|
||||||
|
if !ClassDB.class_exists("Time"):
|
||||||
|
time.free()
|
||||||
|
|
||||||
|
4
Start.gd
4
Start.gd
@ -9,11 +9,11 @@ var array_with_time_to_change: Array = []
|
|||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
for i in Autoload.alone_steps.size() + 1:
|
for i in Autoload.alone_steps.size() + 1:
|
||||||
array_with_time_to_change.append(Autoload.os.get_ticks_msec() + i * Autoload.time_for_each_step)
|
array_with_time_to_change.append(Autoload.time.get_ticks_msec() + i * Autoload.time_for_each_step)
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if current_scene < Autoload.alone_steps.size() - 1 && Autoload.os.get_ticks_msec() > array_with_time_to_change[current_scene + 1]:
|
if current_scene < Autoload.alone_steps.size() - 1 && Autoload.time.get_ticks_msec() > array_with_time_to_change[current_scene + 1]:
|
||||||
current_scene += 1
|
current_scene += 1
|
||||||
|
|
||||||
for child in get_children():
|
for child in get_children():
|
||||||
|
Loading…
Reference in New Issue
Block a user