Skip to content

Commit 48c75f6

Browse files
committed
Fix benchmarks
1 parent aab4f64 commit 48c75f6

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

bench/bench_decode.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ for i, name in ipairs(libs) do
6363
end
6464

6565
-- Warmup (for LuaJIT)
66-
bench.run(name, 1, function() json.decode(text) end)
66+
bench.run(name, 10, function() json.decode(text) end)
6767

6868
-- Run and push results
69-
local res = bench.run(name, 10, function() json.decode(text) end)
69+
local res = bench.run(name, 100, function() json.decode(text) end)
7070
table.insert(results, res)
7171
end
7272

bench/bench_encode.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ for i, name in ipairs(libs) do
5151
end
5252

5353
-- Warmup (for LuaJIT)
54-
bench.run(name, 1, function() json.encode(data) end)
54+
bench.run(name, 10, function() json.encode(data) end)
5555

5656
-- Run and push results
57-
local res = bench.run(name, 10, function() json.encode(data) end)
57+
local res = bench.run(name, 100, function() json.encode(data) end)
5858
table.insert(results, res)
5959
end
6060

bench/util/bench.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ local fmt = string.format
55

66

77
function bench.run(name, count, func)
8+
-- Ensure all garbage is collected
9+
for _ = 1, 10 do -- cycles
10+
collectgarbage()
11+
end
812
-- Run bench
913
local res = {}
1014
for i = 1, count do

0 commit comments

Comments
 (0)