Skip to content

Commit

Permalink
[wip] fix luacheck issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mikz committed May 28, 2018
1 parent fb0ad98 commit ff04f55
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions benchmark/ips.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -294,15 +283,15 @@ 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
end

self:notify('start_running')

for i=1, self.iterations do
for _=1, self.iterations do
self:run_benchmark()
end

Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ff04f55

Please sign in to comment.