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
|
end
|
||||||
|
|
||||||
-- Warmup (for LuaJIT)
|
-- 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
|
-- 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)
|
table.insert(results, res)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -51,10 +51,10 @@ for i, name in ipairs(libs) do
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Warmup (for LuaJIT)
|
-- 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
|
-- 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)
|
table.insert(results, res)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,10 @@ local fmt = string.format
|
||||||
|
|
||||||
|
|
||||||
function bench.run(name, count, func)
|
function bench.run(name, count, func)
|
||||||
|
-- Ensure all garbage is collected
|
||||||
|
for _ = 1, 10 do -- cycles
|
||||||
|
collectgarbage()
|
||||||
|
end
|
||||||
-- Run bench
|
-- Run bench
|
||||||
local res = {}
|
local res = {}
|
||||||
for i = 1, count do
|
for i = 1, count do
|
||||||
|
|
Loading…
Reference in New Issue