1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-17 18:35:20 +02:00

Builtin profiler: Capture Tracy zones; And small improvements (#16479)

* Feature: Use the builtin profiler to automatically make zones for mod callback functions.
* Doc: Basic doc for builtin profiler, and better `/profiler` chatcommand help.
* Fix: `register_functions` (table of callback register function names), and `entity_instrumentation` is no longer outdated.
* Fix: Builtin profiler output is no longer printed to debug.txt or to file in world with translation escapes.
* Fix: Entity callback name generation used `obj_def.label` (normally non-existing field), now it uses the entity name.
* Small code improvements, like use of new `Settings.get_bool` with default.
This commit is contained in:
DS
2025-09-08 18:27:26 +02:00
committed by GitHub
parent c9d4c33174
commit 69497200f9
7 changed files with 171 additions and 92 deletions

View File

@@ -168,7 +168,7 @@ local CsvFormatter = Formatter:new {
end
}
local function format_statistics(profile, format, filter)
local function format_statistics(profile, format, filter, enable_translation)
local formatter
if format == "csv" then
formatter = CsvFormatter:new {
@@ -180,16 +180,20 @@ local function format_statistics(profile, format, filter)
}
end
formatter:format(filter)
return formatter:flush()
local out = formatter:flush()
if not enable_translation then
out = core.get_translated_string("en", out)
end
return out
end
---
-- Format the profile ready for display and
-- @return string to be printed to the console
--
function reporter.print(profile, filter)
function reporter.print(profile, filter, enable_translation)
if filter == "" then filter = nil end
return format_statistics(profile, "txt", filter)
return format_statistics(profile, "txt", filter, enable_translation)
end
---
@@ -215,7 +219,7 @@ local function serialize_profile(profile, format, filter)
end
end
-- Fall back to textual formats.
return format_statistics(profile, format, filter)
return format_statistics(profile, format, filter, false)
end
local worldpath = core.get_worldpath()