From ff04f55c30ad1b1153515de07d21aa9cd6b169c8 Mon Sep 17 00:00:00 2001 From: Michal Cichra Date: Mon, 28 May 2018 19:31:29 +0200 Subject: [PATCH] [wip] fix luacheck issues --- benchmark/ips.lua | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/benchmark/ips.lua b/benchmark/ips.lua index eb675072d..174091bfe 100644 --- a/benchmark/ips.lua +++ b/benchmark/ips.lua @@ -179,7 +179,7 @@ local floor = math.floor -- @treturn Integer Cycles per 100ms. local function cycles_per_100ms(time_nsec, iters) - cycles = floor((NANOSECONDS_PER_100MS / time_nsec) * iters) + local cycles = floor((NANOSECONDS_PER_100MS / time_nsec) * iters) if cycles <= 0 then return 1 else return cycles end end @@ -202,15 +202,15 @@ function IPS:run_warmup() local before = Timing.now() local target = Timing.add_second(before, self.warmup) - warmup_iter = 0 + local warmup_iter = 0 while Timing.now() < target do item:call_times(1) warmup_iter = warmup_iter + 1 end - after = Timing.now() - warmup_time_ns = Timing.time_ns(before, after) + local after = Timing.now() + local warmup_time_ns = Timing.time_ns(before, after) self.timing[item] = cycles_per_100ms(warmup_time_ns, warmup_iter) @@ -228,16 +228,6 @@ local sum = function(t) return total end -local map = function(t, f) - local m = {} - - for i, n in ipairs(t) do - m[i] = f(n) - end - - return m -end - local function stats_samples(measurements_ns, cycles) local samples = tab_new(#measurements_ns, 0) @@ -283,7 +273,6 @@ function IPS:run_benchmark() insert(measurements_ns, iter_ns) end - local final_time = after local measured_ns = sum(measurements_ns) local samples = stats_samples(measurements_ns, cycles) local rep = self.full_report:add_entry(item.label, measured_ns, iter, Stats:new(samples), cycles) @@ -294,7 +283,7 @@ end function IPS:run() if self.warmup and self.warmup > 0 then - for i=1, self.iterations do + for _=1, self.iterations do self:notify('start_warming') self:run_warmup() end @@ -302,7 +291,7 @@ function IPS:run() self:notify('start_running') - for i=1, self.iterations do + for _=1, self.iterations do self:run_benchmark() end @@ -317,7 +306,7 @@ end function Entry:call_times(n) local action = self.action - for i=1, n do + for _=1, n do action() end end @@ -336,8 +325,7 @@ function Report:add_entry(label, nanoseconds, iters, stats, measurement_cycle) return entry end -function Report:body(format) - local left = ("%s (±%4.1f%%) i/s"):format() +function Report.body(_) end function ReportEntry:new(label, nanoseconds, iterations, stats, measurement_cycle) @@ -365,8 +353,8 @@ function ReportEntry:runtime() end local function stat_mean(samples) - local sum = sum(samples) - return sum / #samples + local total = sum(samples) + return total / #samples end local function stat_variance(samples, m)