From 9720bb9f10d9b8ef7969a0f67e41be4e3e170b4d Mon Sep 17 00:00:00 2001 From: rxi Date: Fri, 14 Aug 2015 19:21:42 +0100 Subject: [PATCH] Added warmup for JIT in benchmark scripts --- bench/bench_decode.lua | 3 +++ bench/bench_encode.lua | 3 +++ 2 files changed, 6 insertions(+) diff --git a/bench/bench_decode.lua b/bench/bench_decode.lua index fd94e0e..6c2e93a 100644 --- a/bench/bench_decode.lua +++ b/bench/bench_decode.lua @@ -62,6 +62,9 @@ for i, name in ipairs(libs) do json.decode = function(...) return _decode(json, ...) end end + -- Warmup (for LuaJIT) + bench.run(name, 1, function() json.decode(text) end) + -- Run and push results local res = bench.run(name, 10, function() json.decode(text) end) table.insert(results, res) diff --git a/bench/bench_encode.lua b/bench/bench_encode.lua index 119e2d8..426f7c8 100644 --- a/bench/bench_encode.lua +++ b/bench/bench_encode.lua @@ -50,6 +50,9 @@ for i, name in ipairs(libs) do json.decode = function(...) return _decode(json, ...) end end + -- Warmup (for LuaJIT) + bench.run(name, 1, function() json.encode(data) end) + -- Run and push results local res = bench.run(name, 10, function() json.encode(data) end) table.insert(results, res)