Skip to content

Commit 8cb56f3

Browse files
committed
Changed decode benchmark script to prevent use of lpeg
1 parent c8e460b commit 8cb56f3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bench/bench_decode.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ local text = "[" .. string.rep([[{
3636
}, ]], 1000):sub(1, -3) .. "]"
3737

3838

39+
-- As this is meant to be a pure Lua benchmark, we remove the ability to
40+
-- require 'lpeg' so dkjson doesn't use it for parsing. (Incidentally json.lua
41+
-- seems to outperform libraries which use lpeg when both are using LuaJIT)
42+
local _require = require
43+
require = function(modname)
44+
if modname == "lpeg" then error() end
45+
return _require(modname)
46+
end
47+
3948
-- Run benchmarks, store results
4049
local results = {}
4150

@@ -46,7 +55,7 @@ for i, name in ipairs(libs) do
4655
end
4756
local json = f()
4857

49-
-- Handle special cases
58+
-- Remap functions to work for jfjson.lua
5059
if name == "jfjson.lua" then
5160
local _encode, _decode = json.encode, json.decode
5261
json.encode = function(...) return _encode(json, ...) end

0 commit comments

Comments
 (0)