Add init time tracking
This commit is contained in:
parent
5a02c10080
commit
708913ae7e
1 changed files with 21 additions and 0 deletions
21
src/core.gd
21
src/core.gd
|
@ -75,8 +75,22 @@ var disabled: bool = false
|
|||
# Displays the ✨ special ✨ welcome message if true
|
||||
var welcomed: bool = false
|
||||
|
||||
## Contains the amount of time it took to preinitialize the framework, measured in milliseconds.[br]
|
||||
## Captured in [method _init].[br]
|
||||
## [b]Danger: [i]Don't modify this.[/i][/b]
|
||||
var initduration_preinitialization: int = 0
|
||||
## Contains the amount of time it took to initialize the framework, measured in milliseconds.[br]
|
||||
## Captured in [method _ready].[br]
|
||||
## [b]Danger: [i]Don't modify this.[/i][/b]
|
||||
var initduration_initialization: int = 0
|
||||
## Contains the amount of time it took to completely initialize the framework, measured in milliseconds.[br]
|
||||
## Captured in [method complete_init].[br]
|
||||
## [b]Danger: [i]Don't modify this.[/i][/b]
|
||||
var initduration_complete_initialization: int = 0
|
||||
|
||||
# +++ initialization +++
|
||||
func _init(new_config: CoreConfiguration = CoreConfiguration.new()) -> void:
|
||||
var inittime: int = Time.get_ticks_msec()
|
||||
name = "CORE"
|
||||
if !check_godot_version(): return
|
||||
if !determine_basepath(): queue_free()
|
||||
|
@ -85,14 +99,17 @@ func _init(new_config: CoreConfiguration = CoreConfiguration.new()) -> void:
|
|||
initialize_modules()
|
||||
apply_configuration()
|
||||
initialize_scheduler()
|
||||
initduration_preinitialization = Time.get_ticks_msec() - inittime
|
||||
|
||||
func _ready() -> void:
|
||||
var inittime: int = Time.get_ticks_msec()
|
||||
inject_modules()
|
||||
custom_modules_node.name = "Custom Modules"
|
||||
add_child(custom_modules_node)
|
||||
loggeri = logger.get_instance(basepath.replace("res://", "") + "src/core.gd", self)
|
||||
add_child(scheduler)
|
||||
get_tree().auto_accept_quit = false
|
||||
initduration_initialization = Time.get_ticks_msec() - inittime
|
||||
|
||||
# Initializes all built-in modules during the preinitialization phase.
|
||||
## Internal, don't call.
|
||||
|
@ -130,6 +147,7 @@ func initialize_scheduler() -> void:
|
|||
## This ensures that all modules are fully initialized and ready for usage.[br]
|
||||
## [i][b]Not calling this function during startup may lead to runtime issues.[/b][/i]
|
||||
func complete_init() -> void:
|
||||
var inittime: int = Time.get_ticks_msec()
|
||||
var modsinit_builtin: Array[String] = ["workaround"]
|
||||
var modsinit_custom: Array[String] = ["workaround"]
|
||||
|
||||
|
@ -152,6 +170,8 @@ func complete_init() -> void:
|
|||
if modsinit_custom.size() != 0: print(" Custom: " + str(modsinit_custom))
|
||||
await get_tree().create_timer(1).timeout
|
||||
|
||||
initduration_complete_initialization = Time.get_ticks_msec() - inittime
|
||||
|
||||
# Initialization complete
|
||||
await get_tree().process_frame
|
||||
if !welcomed:
|
||||
|
@ -168,6 +188,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
|
||||
Consider contributing to the CORE Framework to make it even better... and remember: #TransRightsAreHumanRights
|
||||
Thank you for using the CORE Framework to develop your application or game!""")
|
||||
loggeri.info("Framework initialization took " + str(initduration_preinitialization + initduration_initialization + initduration_complete_initialization) + "ms (pre " + str(initduration_preinitialization) + "ms, init " + str(initduration_initialization) + "ms, complete " + str(initduration_complete_initialization) + "ms)")
|
||||
if is_devmode(): loggeri.warn("The CORE Framework is running in development mode.\nThis may cause bugs and issues inside the framework. Here be dragons!")
|
||||
if logger.verbose_mode: loggeri.warn("Godot is running in verbose stdout mode.\nDue to a bug in the engine that prevents displaying truecolor ANSI escape\nsequences CORE changed the color of all diagnostic log messages.\nTo prevent this, set 'logger_detect_verbose_mode' in the configuration to 'false'.")
|
||||
|
||||
|
|
Loading…
Reference in a new issue