lua-users home
lua-l archive

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


Thanks & thanks for that lua-users JSON reference page. I found it extremely helpful as starting point for understanding the individual JSON packages.

Henning

On 3/22/11 12:30 AM, David Kolf wrote:
Henning Diedrich wrote:
If someone knows the benchmark code used for
http://lua-users.org/wiki/JsonModules, please let me know.
It was just a quick test using the JSON data from
http://de.wikipedia.org/wiki/JSON#Beispiel

The following scripts were called using Lua 5.1.4 and measured using the
GNU/Linux "time" command. I used "-e" to add the necessary require-calls
for each JSON-module.

Those benchmarks might not be the best, I do not how representable the
test data is. I just wanted to give a rough orientation. In my opinion
standard compliance is a lot more important than speed.

Oh, that reminds me, I still haven't documented and published the new
version of my library that has been sitting on my hard drive for a few
months now. Is anybody except me actually using my library? I guess JSON
looks easy enough to tempt a "make your own" anyway. I mainly published
my version because I didn't find a version at the time that was standard
compliant -- except maybe Lua-Yajl, which only had a minor problem when
decoding.

-----------------------------
-- For encoding:

local tbl = {
  Herausgeber= "Xema",
  Nummer= "1234-5678-9012-3456",
  Deckung= 2e+6,
  ["Währung"]= "EURO",
  Inhaber= {
    Name= "Reich",
    Vorname= "Rainer",
    ["männlich"]= true,
    Hobbys= { "Reiten", "Golfen", "Lesen" },
    Alter= 42,
    --SozialesGewissen= nil
    SozialesGewissen= json.null
  }
}
for i = 1,100000 do
  json.encode (tbl)
end

-----------------------------
-- For decoding:

local str = [[
{
  "Herausgeber": "Xema",
  "Nummer": "1234-5678-9012-3456",
  "Deckung": 2e+6,
  "Währung": "EURO",
  "Inhaber": {
    "Name": "Reich",
    "Vorname": "Rainer",
    "männlich": true,
    "Hobbys": [ "Reiten", "Golfen", "Lesen" ],
    "Alter": 42,
    "SozialesGewissen": null
  }
}
]]
for i = 1,100000 do
  json.decode (str)
end