mirror of https://github.com/rxi/json.lua.git
Fix benchmarks
parent
aab4f644b6
commit
48c75f6036
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue