This looks interesting. Its handy to be able to see how much load code is producing. Especially when trying to work out which of multiple versions of code run the best.
This is the first time I’ve seen this, so correct me if I’m wrong. The graph shows each stack of code as a proportion of the ‘all’. This could be most useful for testing something like a global step callback for load on the game, but is harder to determine an arbitrary piece of running code.
I added a chat command
jitprofiler_benchmark <integer>. This command concatenates a string one character at a time to
<length>. This provides a fixed load (assuming the length is the same) as a comparative across test.
Code: Select all
local function benchmark (length)
local s = ""
for a = 1, length, 1 do
s = s.."a"
end
end
minetest.register_chatcommand("jitprofiler_benchmark", {
description = "Benchmark LuaJIT's profiler",
params = "<length>",
privs = {server = true},
func = function(_name, param)
if not outfile then
return false, "Profiler not running"
end
local length = tonumber (param)
if type (length) ~= "number" or length < 1 then
return false, "Invalid benchmark size"
end
benchmark (length)
return true, "Profiler benchmark "..tostring (length).." complete"
end,
})
The load is in a separate function so it shows in the profile.
In the following the stack on the left is the fixed load, and the stack on the right is the code being tested.
- test.png (42.66 KiB) Viewed 3256 times
In the tests the first runs some in-game code in a computer, and the second runs the same code about five times. While the fixed load is proportionately different it is the same benchmark command length. This is a useless test but its only for demonstration.
This doesn’t provide an empirical measure of load, but provides a good comparative. I think its easier to guesstimate how much demand a piece of code is producing, and easier to determine which of two code versions makes less demand.
I tried this with lwcomputers, which turn jit off for sandboxing, and it ran OK. I don’t know if this means anything with regards to luacontrollers.