Fix syntax errors

master
orwell96 2019-12-05 10:17:17 +01:00
parent 9ea4002b6b
commit 38e8f0e1f2
1 changed files with 14 additions and 13 deletions

View File

@ -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