lua-users home
lua-l archive

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


Jerome Vuarand wrote:
Hi list,

I have an application that do intense use of JSON (a CouchDB view
server and client library). I started with JSON4Lua, which is pure Lua
but was way too slow for big structures. I switched to luajson, which
is based on lpeg, and achieved to do in milliseconds what JSON4Lua
sometimes took minutes to do.

Now in my view server, for simple views and relatively big datasets
(so that the code is mostly dominated by JSON conversions), Lua is
approximately 10 to 20% faster than JavaScript (SpiderMonkey 1.7.0).

So my question is, can I expect a significative performance
improvement by using a JSON parsing library written in pure C (that
would use the Lua C API for data structures construction) as opposed
to luajson lpeg parser that does the construction from Lua code ?

Regards,

Doub.


Perhaps a benchmark is in order?

YAJL is reportedly among the fastest C JSON libs around. There is a Lua module for it here:

http://github.com/brimworks/lua-yajl/

A trivial bench between lua-yajl and json4lua encoding a small array 100,000 times shows this:

alpha# time lua-5.1 yajltest.lua
3.967u 0.000s 0:03.97 99.7%     177+983k 0+0io 0pf+0w

alpha# time lua-5.1 jsontest.lua
9.170u 0.000s 0:09.17 100.0%    175+973k 0+0io 0pf+0w

230% faster is what I am seeing - YMMV

--

Stefan