Fix benchmarks

pull/46/head
Lars Mueller 2022-12-17 16:17:51 +01:00
parent aab4f644b6
commit 48c75f6036
3 changed files with 8 additions and 4 deletions

View File

@ -63,10 +63,10 @@ for i, name in ipairs(libs) do
end
-- Warmup (for LuaJIT)
bench.run(name, 1, function() json.decode(text) end)
bench.run(name, 10, function() json.decode(text) end)
-- Run and push results
local res = bench.run(name, 10, function() json.decode(text) end)
local res = bench.run(name, 100, function() json.decode(text) end)
table.insert(results, res)
end

View File

@ -51,10 +51,10 @@ for i, name in ipairs(libs) do
end
-- Warmup (for LuaJIT)
bench.run(name, 1, function() json.encode(data) end)
bench.run(name, 10, function() json.encode(data) end)
-- Run and push results
local res = bench.run(name, 10, function() json.encode(data) end)
local res = bench.run(name, 100, function() json.encode(data) end)
table.insert(results, res)
end

View File

@ -5,6 +5,10 @@ local fmt = string.format
function bench.run(name, count, func)
-- Ensure all garbage is collected
for _ = 1, 10 do -- cycles
collectgarbage()
end
-- Run bench
local res = {}
for i = 1, count do