diff options
author | orwell96 <orwell@bleipb.de> | 2019-12-05 08:21:25 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2019-12-05 08:21:25 +0100 |
commit | 9ea4002b6bfa8b26be9a3a31978c05e865177a97 (patch) | |
tree | 5f179c80ea7b0dbedb5cf959b0a9bcf61b8f7e55 | |
parent | fbbed0899327a1d70676775c2bdeb42b9f06e980 (diff) | |
download | advprofiler-9ea4002b6bfa8b26be9a3a31978c05e865177a97.tar.gz advprofiler-9ea4002b6bfa8b26be9a3a31978c05e865177a97.tar.bz2 advprofiler-9ea4002b6bfa8b26be9a3a31978c05e865177a97.zip |
Make implementation complete
-rw-r--r-- | init.lua | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -5,6 +5,8 @@ advprofiler = {} +local WINDOW_SIZE = 2048 + --[[ Unit table: @@ -33,6 +35,10 @@ local _profs = {} advprofiler._profilers = _profs +local function logs(t) + minetest.log("action", "[advprofiler] "..t) +end + local function warning(prof, unit, text) minetest.log("warning", "[advprofiler] ("..prof.name..":"..unit..") "..text end @@ -153,6 +159,7 @@ function advprofiler.new_profiler(name) } setmetatable(new, prof_mt) table.insert(_profs, new) + logs("Registered profiler "..name) return new end @@ -164,6 +171,19 @@ function advprofiler.step() end end +function advprofiler.end_window_and_report(cyc) + local print_table = { + "--- Profiling report for cycle "..cyc.." ---" + } + for _,prof in ipairs(_profs) do + prof:end_window(print_table) + end + + for _,l in ipairs(print_table) do + logs(l) + end +end + --[[ Report table: @@ -180,4 +200,22 @@ function advprofiler.report(rep) end +--===========-- + +local stepcnt = 0 +local cyccnt = 0 + +minetest.register_globalstep(function(dtime) + + advprofiler.step() + + stepcnt = (stepcnt + 1) % WINDOW_SIZE + + if stepcnt == 0 then + cyccnt = cyccnt + 1 + advprofiler.end_window_and_report(cyccnt) + end + +end) + |