I noticed that _format_data incurs a significant overhead by looking up the script names and class names. I added two simple dictionary as cache to hide it, something like this.
static var GLOBAL_PATH_FILTER_CACHE := {}
static var GLOBAL_SCRIPT_CACHE := {}
static func _get_format_data(entry:LogStream.LogEntry)->Dictionary:
var now = Time.get_datetime_dict_from_system(USE_UTC_TIME_FORMAT)
var log_call = null
var script = ""
var script_class_name = ""
if !entry.stack.is_empty():
log_call = entry.stack[0]
var source = log_call["source"]
if source in GLOBAL_SCRIPT_CACHE:
script = GLOBAL_SCRIPT_CACHE[source]
else:
script = source.split("/")[-1]
GLOBAL_SCRIPT_CACHE[source] = script
var result
if entry in GLOBAL_PATH_FILTER_CACHE:
result = GLOBAL_PATH_FILTER_CACHE[entry]
else:
result = GLOBAL_PATH_LIST.filter(func(entry):return entry["path"] == source)
GLOBAL_PATH_FILTER_CACHE[entry] = result
script_class_name = script if result.is_empty() else result[0]["class"]
Should hold as long as the scripts don't change while game's running. you are welcomed to test the improvements.
I noticed that _format_data incurs a significant overhead by looking up the script names and class names. I added two simple dictionary as cache to hide it, something like this.
Should hold as long as the scripts don't change while game's running. you are welcomed to test the improvements.