diff options
Diffstat (limited to '')
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | chatcommands.lua | 27 |
2 files changed, 28 insertions, 0 deletions
@@ -26,6 +26,7 @@ All of these commands require the `mesecons_debug` privilege. * `/mesecons_enable` Enable the mesecons queue * `/mesecons_disable` Disables the mesecons queue * `/mesecons_stats` shows some mesecons stats for the current position +* `/mesecons_global_stats` shows the mapblock with the most prominent usage of mesecons activity * `/mesecons_whitelist_get` shows the list of whitelisted mapblocks * `/mesecons_whitelist_add` adds the current mapblock to the whitelist * `/mesecons_whitelist_remove` removes the current mapblock from the whitelist 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) |