Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Performance compared to Lua #149

@mingodad

Description

@mingodad

Is your feature request related to a problem? Please describe.
Comparing performance of json parser with Lua show that PeppaPEG is 2x memory hungry and takes 2x more time.

Describe the solution you'd like
At least the same performance or better.

Here is the Lua script using dkjson (http://dkolf.de/src/dkjson-lua.fsl/home):

local json = require ("dkjson")

local str = io.open(arg[1]):read("a*")

local obj, pos, err = json.decode (str, 1, nil)
if err then
  print ("Error:", err)
else
  for k,v in pairs(obj) do
    print (k, type(v))
  end
end

And here is the script testing all with this file as imput (https://github.com/rust-lang/rls/blob/master/rls-analysis/test_data/rls-analysis/librls_data.json 7MB) :

#!/bin/sh
fname="rustc-1.49.0-src/src/tools/rls/rls-analysis/test_data/rls-analysis/librls_data.json"
/usr/bin/time lua decode-json-file.lua $fname
/usr/bin/time lua decode-json-file-lpeg.lua $fname

/usr/bin/time PeppaPEG-DAD/cli parse -G json.peg -e entry $fname > /dev/null

And here is the output:

./test-big.sh
compilation	table
refs	table
config	table
defs	table
imports	table
version	string
relations	table
impls	table
prelude	table
macro_refs	table
1.23user 0.00system 0:01.23elapsed 100%CPU (0avgtext+0avgdata 59844maxresident)k
0inputs+0outputs (0major+16432minor)pagefaults 0swaps
config	table
imports	table
defs	table
compilation	table
refs	table
impls	table
macro_refs	table
version	string
relations	table
prelude	table
0.37user 0.01system 0:00.38elapsed 99%CPU (0avgtext+0avgdata 37248maxresident)k
0inputs+0outputs (0major+10731minor)pagefaults 0swaps
0	true
2.87user 0.02system 0:02.89elapsed 99%CPU (0avgtext+0avgdata 124372maxresident)k
0inputs+0outputs (0major+30745minor)pagefaults 0swaps

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions