aboutsummaryrefslogtreecommitdiff
path: root/lib/lua/src
ModeNameSize
-rw-r--r--CMakeLists.txt695logplain
-rw-r--r--lapi.c22708logplain
-rw-r--r--lapi.h262logplain
-rw-r--r--lauxlib.c17417logplain
-rw-r--r--lauxlib.h5777logplain
-rw-r--r--lbaselib.c17045logplain
-rw-r--r--lcode.c21170logplain
-rw-r--r--lcode.h2750logplain
-rw-r--r--ldblib.c10092logplain
-rw-r--r--ldebug.c16840logplain
-rw-r--r--ldebug.h1061logplain
-rw-r--r--ldo.c14892logplain
-rw-r--r--ldo.h1897logplain
-rw-r--r--ldump.c3114logplain
-rw-r--r--lfunc.c4618logplain
-rw-r--r--lfunc.h1125logplain
-rw-r--r--lgc.c20053logplain
-rw-r--r--lgc.h3159logplain
-rw-r--r--linit.c765logplain
-rw-r--r--liolib.c13466logplain
-rw-r--r--llex.c12583logplain
-rw-r--r--llex.h2177logplain
-rw-r--r--llimits.h2349logplain
-rw-r--r--lmathlib.c5831logplain
-rw-r--r--lmem.c2172logplain
-rw-r--r--lmem.h1494logplain
-rw-r--r--loadlib.c19216logplain
-rw-r--r--lobject.c5498logplain
-rw-r--r--lobject.h8502logplain
-rw-r--r--lopcodes.c2884logplain
-rw-r--r--lopcodes.h8086logplain
-rw-r--r--loslib.c5992logplain
-rw-r--r--lparser.c36696logplain
-rw-r--r--lparser.h2261logplain
-rw-r--r--lstate.c5674logplain
-rw-r--r--lstate.h5011logplain
-rw-r--r--lstring.c3110logplain
-rw-r--r--lstring.h814logplain
-rw-r--r--lstrlib.c23561logplain
-rw-r--r--ltable.c16263logplain
-rw-r--r--ltable.h1184logplain
-rw-r--r--ltablib.c7343logplain
-rw-r--r--ltm.c1650logplain
-rw-r--r--ltm.h1018logplain
-rw-r--r--lua.c10163logplain
-rw-r--r--lua.h11688logplain
-rw-r--r--luac.c4661logplain
-rw-r--r--luaconf.h22299logplain
-rw-r--r--lualib.h1026logplain
-rw-r--r--lundump.c4629logplain
-rw-r--r--lundump.h890logplain
-rw-r--r--lvm.c23242logplain
-rw-r--r--lvm.h1159logplain
-rw-r--r--lzio.c1628logplain
-rw-r--r--lzio.h1556logplain
-rw-r--r--print.c4944logplain
/span> mod_statistics.stats["total"].avg_us = mod_statistics.stats["total"].avg_us * 0.99 + mod_statistics.step_total * 0.01 mod_statistics.step_total = 0 end -------------------------------------------------------------------------------- local function build_callback(log_id, fct) return function( toregister ) local modname = core.get_current_modname() fct(function(...) local starttime = core.get_us_time() -- note maximum 10 return values are supported unless someone finds -- a way to store a variable lenght return value list local r0, r1, r2, r3, r4, r5, r6, r7, r8, r9 = toregister(...) local delta = core.get_us_time() - starttime mod_statistics.log_time(log_id, modname, delta) return r0, r1, r2, r3, r4, r5, r6, r7, r8, r9 end ) end end -------------------------------------------------------------------------------- function profiling_print_log(cmd, filter) print("Filter:" .. dump(filter)) core.log("action", "Values below show times/percentages per server step.") core.log("action", "Following suffixes are used for entities:") core.log("action", "\t#oa := on_activate, #os := on_step, #op := on_punch, #or := on_rightclick, #gs := get_staticdata") core.log("action", string.format("%16s | %25s | %10s | %10s | %10s | %9s | %9s | %9s", "modname", "type" , "min µs", "max µs", "avg µs", "min %", "max %", "avg %") ) core.log("action", "-----------------+---------------------------+-----------+" .. "-----------+-----------+-----------+-----------+-----------") for modname,statistics in pairs(mod_statistics.stats) do if modname ~= "total" then if (filter == "") or (modname == filter) then if modname:len() > 16 then modname = "..." .. modname:sub(-13) end core.log("action", string.format("%16s | %25s | %9d | %9d | %9d | %9d | %9d | %9d", modname, " ", statistics.min_us, statistics.max_us, statistics.avg_us, statistics.min_per, statistics.max_per, statistics.avg_per) ) if core.setting_getbool("detailed_profiling") then if statistics.types ~= nil then for type,typestats in pairs(statistics.types) do if type:len() > 25 then type = "..." .. type:sub(-22) end core.log("action", string.format( "%16s | %25s | %9d | %9d | %9d | %9d | %9d | %9d", " ", type, typestats.min_us, typestats.max_us, typestats.avg_us, typestats.min_per, typestats.max_per, typestats.avg_per) ) end end end end end end core.log("action", "-----------------+---------------------------+-----------+" .. "-----------+-----------+-----------+-----------+-----------") if filter == "" then core.log("action", string.format("%16s | %25s | %9d | %9d | %9d | %9d | %9d | %9d", "total", " ", mod_statistics.stats["total"].min_us, mod_statistics.stats["total"].max_us, mod_statistics.stats["total"].avg_us, mod_statistics.stats["total"].min_per, mod_statistics.stats["total"].max_per, mod_statistics.stats["total"].avg_per) ) end core.log("action", " ") return true end -------------------------------------------------------------------------------- local function initialize_profiling() core.log("action", "Initialize tracing") mod_statistics.entity_callbacks = {} -- first register our own globalstep handler core.register_globalstep(mod_statistics.update_statistics) local rp_register_entity = core.register_entity core.register_entity = function(name, prototype) local modname = core.get_current_modname() local new_on_activate = nil local new_on_step = nil local new_on_punch = nil local new_rightclick = nil local new_get_staticdata = nil if prototype.on_activate ~= nil then local cbid = name .. "#oa" mod_statistics.entity_callbacks[cbid] = prototype.on_activate new_on_activate = function(self, staticdata, dtime_s) local starttime = core.get_us_time() mod_statistics.entity_callbacks[cbid](self, staticdata, dtime_s) local delta = core.get_us_time() -starttime mod_statistics.log_time(cbid, modname, delta) end end if prototype.on_step ~= nil then local cbid = name .. "#os" mod_statistics.entity_callbacks[cbid] = prototype.on_step new_on_step = function(self, dtime) local starttime = core.get_us_time() mod_statistics.entity_callbacks[cbid](self, dtime) local delta = core.get_us_time() -starttime mod_statistics.log_time(cbid, modname, delta) end end if prototype.on_punch ~= nil then local cbid = name .. "#op" mod_statistics.entity_callbacks[cbid] = prototype.on_punch new_on_punch = function(self, hitter) local starttime = core.get_us_time() mod_statistics.entity_callbacks[cbid](self, hitter) local delta = core.get_us_time() -starttime mod_statistics.log_time(cbid, modname, delta) end end if prototype.rightclick ~= nil then local cbid = name .. "#rc" mod_statistics.entity_callbacks[cbid] = prototype.rightclick new_rightclick = function(self, clicker) local starttime = core.get_us_time() mod_statistics.entity_callbacks[cbid](self, clicker) local delta = core.get_us_time() -starttime mod_statistics.log_time(cbid, modname, delta) end end if prototype.get_staticdata ~= nil then local cbid = name .. "#gs" mod_statistics.entity_callbacks[cbid] = prototype.get_staticdata new_get_staticdata = function(self) local starttime = core.get_us_time() local retval = mod_statistics.entity_callbacks[cbid](self) local delta = core.get_us_time() -starttime mod_statistics.log_time(cbid, modname, delta) return retval end end prototype.on_activate = new_on_activate prototype.on_step = new_on_step prototype.on_punch = new_on_punch prototype.rightclick = new_rightclick prototype.get_staticdata = new_get_staticdata rp_register_entity(name,prototype) end for i,v in ipairs(replacement_table) do local to_replace = core[v] core[v] = build_callback(v, to_replace) end local rp_register_abm = core.register_abm core.register_abm = function(spec) local modname = core.get_current_modname() local replacement_spec = { nodenames = spec.nodenames, neighbors = spec.neighbors, interval = spec.interval, chance = spec.chance, action = function(pos, node, active_object_count, active_object_count_wider) local starttime = core.get_us_time() spec.action(pos, node, active_object_count, active_object_count_wider) local delta = core.get_us_time() - starttime mod_statistics.log_time("abm", modname, delta) end } rp_register_abm(replacement_spec) end core.log("action", "Mod profiling initialized") end initialize_profiling()