diff --git a/bench/bench_decode.lua b/bench/bench_decode.lua index 6c2e93a..4058c8a 100644 --- a/bench/bench_decode.lua +++ b/bench/bench_decode.lua @@ -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 diff --git a/bench/bench_encode.lua b/bench/bench_encode.lua index 426f7c8..d8a9441 100644 --- a/bench/bench_encode.lua +++ b/bench/bench_encode.lua @@ -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 diff --git a/bench/util/bench.lua b/bench/util/bench.lua index 9f02738..95f9aa6 100644 --- a/bench/util/bench.lua +++ b/bench/util/bench.lua @@ -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