diff options
author | BuckarooBanzay <BuckarooBanzay@users.noreply.github.com> | 2020-10-28 15:47:52 +0100 |
---|---|---|
committer | BuckarooBanzay <BuckarooBanzay@users.noreply.github.com> | 2020-10-28 15:47:52 +0100 |
commit | dec459e5fd6e3c356c7906f2456ed9fb95bd4bb4 (patch) | |
tree | b87062b4ee12874a0501f4bc0765c7c7f08d9e92 /chatcommands.lua | |
parent | fbf6777c299b665884875e2afe76f791c8f7ab74 (diff) | |
download | mesecons_debug-dec459e5fd6e3c356c7906f2456ed9fb95bd4bb4.tar.gz mesecons_debug-dec459e5fd6e3c356c7906f2456ed9fb95bd4bb4.zip |
add /mesecons_global_stats command
Diffstat (limited to '')
-rw-r--r-- | chatcommands.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/chatcommands.lua b/chatcommands.lua index 87b7845..034dd5e 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -13,6 +13,33 @@ minetest.register_chatcommand("mesecons_hud", { end }) +minetest.register_chatcommand("mesecons_global_stats", { + description = "shows the global mesecons stats", + func = function() + local top_ctx, top_hash + + for hash, ctx in pairs(mesecons_debug.context_store) do + if not top_ctx or top_ctx.avg_micros < ctx.avg_micros then + -- store context with the most average time + top_ctx = ctx + top_hash = hash + end + end + + local txt + if top_ctx then + local pos = minetest.get_position_from_hash(top_hash) + + txt = "Most prominent mesecons usage at mapblock " .. minetest.pos_to_string(pos) .. + " with " .. top_ctx .. " seconds penalty and " .. top_ctx.avg_micros .. " us average use" + else + txt = "no context available" + end + + return true, txt + end +}) + minetest.register_chatcommand("mesecons_stats", { description = "shows some mesecons stats for the current position", func = function(name) |