aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-12-05 10:17:17 +0100
committerorwell96 <orwell@bleipb.de>2019-12-05 10:17:17 +0100
commit38e8f0e1f2cf1d721950939d14895e04114077f2 (patch)
tree35edff36ede75d22add3e5c2512fe2433540a301
parent9ea4002b6bfa8b26be9a3a31978c05e865177a97 (diff)
downloadadvprofiler-38e8f0e1f2cf1d721950939d14895e04114077f2.zip
advprofiler-38e8f0e1f2cf1d721950939d14895e04114077f2.tar.gz
advprofiler-38e8f0e1f2cf1d721950939d14895e04114077f2.tar.bz2
Fix syntax errors
-rw-r--r--init.lua27
1 files changed, 14 insertions, 13 deletions
diff --git a/init.lua b/init.lua
index ca5eb20..5bfecce 100644
--- a/init.lua
+++ b/init.lua
@@ -5,7 +5,7 @@
advprofiler = {}
-local WINDOW_SIZE = 2048
+local WINDOW_SIZE = 1024
--[[
@@ -40,7 +40,7 @@ local function logs(t)
end
local function warning(prof, unit, text)
- minetest.log("warning", "[advprofiler] ("..prof.name..":"..unit..") "..text
+ minetest.log("warning", "[advprofiler] ("..prof.name..":"..unit..") "..text)
end
local clock = os.clock
@@ -65,9 +65,9 @@ function profiler:unit_get(unit)
-- create unit new
self.units[unit] = {
st_counts = {},
- st_times_tot = {...}
- st_times_max = {...}
- st_times_avg = {...}
+ st_times_tot = {},
+ st_times_max = {},
+ st_times_avg = {},
st_stepcount = 0,
rn_times = {},
@@ -75,6 +75,7 @@ function profiler:unit_get(unit)
rn_count = 0,
}
+ return self.units[unit]
end
function profiler:count(unitn, count_inc)
@@ -115,9 +116,9 @@ function profiler:end_step()
local sc = unit.st_stepcount + 1
unit.st_counts[sc] = unit.rn_count
local rt_tot, rt_avg, rt_max = accumulate(unit.rn_times, unit.rn_runcount)
- unit.st_times_tot = rt_tot
- unit.st_times_max = rt_max
- unit.st_times_avg = rt_avg
+ unit.st_times_tot[sc] = rt_tot
+ unit.st_times_max[sc] = rt_max
+ unit.st_times_avg[sc] = rt_avg
unit.st_stepcount = sc
unit.rn_runcount = 0
@@ -126,7 +127,7 @@ function profiler:end_step()
end
function profiler:end_window(print_table)
- table.insert(print_table, "=== "..profiler.name.." ===")
+ table.insert(print_table, "=== "..self.name.." ===")
for unitn, unit in pairs(self.units) do
if unit.enter_ts then
warning(self,unitn,"Unit still entered at end of step! (discarding)")
@@ -137,12 +138,12 @@ function profiler:end_window(print_table)
profiler = self,
unit = unitn,
}
- rep.count_tot, rep.count_avg, rep.count_max = accumulate(unit.st_count, sc)
+ rep.count_tot, rep.count_avg, rep.count_max = accumulate(unit.st_counts, sc)
rep.time_tot, rep.time_avg, rep.time_max = accumulate(unit.st_times_tot, sc)
local report_f = unit.report or advprofiler.report
- table.insert(print_table, unitn..": "..report_f(rep))
+ table.insert(print_table, unitn..":\t"..report_f(rep))
unit.st_stepcount = 0
end
@@ -194,9 +195,9 @@ rep.time_tot, rep.time_avg, rep.time_max
function advprofiler.report(rep)
- return string.format("Count avg=%d max=%d total=%d | Time avg=%3fms max=%3fms total=%3fms"
+ return string.format("Count avg=%d\tmax=%d\ttotal=%d\tTime avg=%dms\tmax=%dms\ttotal=%dms",
rep.count_avg, rep.count_max, rep.count_tot,
- rep.time_avg, rep.time_max, rep.time_tot)
+ rep.time_avg*1000, rep.time_max*1000, rep.time_tot*1000)
end