lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I have just add a simple test on Windows 7 with LuaJIT 2.0.3:

It seem: 

* json is faster when decoding (especially large data)
* cjson is faster when encoding data

but json have more feature when encoding (ordered keys, and try to do best detect for table types).

I'll add performance test in travis and appveyor later.

Detailed test result:

[rapidjson/bin/data/sample.json][1]:
json.decode()   1.3516025543213
cjson.decode()  2.2664051055908
json.encode()   2.2368049621582
cjson.encode()  1.3914031982422

[rapidjson/bin/data/webapp.json][2]:
json.decode()   2.4480056762695
cjson.decode()  2.6756038665771
json.encode()   2.6312065124512
cjson.encode()  2.0330047607422


[1]:https://github.com/xpol/json/blob/master/rapidjson/bin/data/sample.json
[2]:https://github.com/xpol/json/blob/master/rapidjson/bin/data/webapp.json


On Mon, Mar 30, 2015 at 11:02 PM Valerio Schiavoni <valerio.schiavoni@gmail.com> wrote:
hi,
in terms of raw performance, how does it compare with the lua-cjson library ? 

https://github.com/mpx/lua-cjson/


thanks,
Valerio

On Wed, Mar 25, 2015 at 9:10 AM, Xpol Wan <xpolife@gmail.com> wrote:
json is a module that provide fast json APIs for lua.

It based on the RapidJSON ( [1]) library.

APIs included:

- `json.decode()` decode json to lua table.
- `json.encode()` encode lua table to json string.
- `json.load()` load json file into lua table.
- `json.dump()` dump lua table to json file.

It has tested with Lua 5.1 5.2 5.3 and LuaJIT 2.0 2.1 on Windows 7,  Linux (travis) and MacOS 10.10 [footnote].

Please visit GitHub project for source, documentation (in README.md), bug report and discussions:


It also have submitted to luarocks [2], just

> luarocks install json




--------------------------

[footnote]: for MacOS with Lua 5.2, the follow 2 test expected error in are not passed(no error raised):


Suggestion and help about the 2 test are welcomed!


Best Regards!

Xpol Wan
// There is a better way!