blob: b5b1a7724bc4411b2d8d482c2ab0559d7bd8d18d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/usr/bin/env lua
-- Simple JSON benchmark.
--
-- Your Mileage May Vary.
require "common"
local json = require "cjson"
--local json = require "json"
--local json = require "dkjson"
function bench_file(filename)
local data_json = file_load(filename)
local data_obj = json.decode(data_json)
local function test_encode ()
json.encode(data_obj)
end
local function test_decode ()
json.decode(data_json)
end
local tests = {
encode = test_encode,
decode = test_decode
}
return benchmark(tests, 5000, 5)
end
i = 1
while arg[i] do
local results = {}
results[arg[i]] = bench_file(arg[i])
dump_value(results)
i = i + 1
end
-- vi:ai et sw=4 ts=4:
|