blob: 847365bf6891b62c3d5878c4bf502acb24f053e3 (
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
|
#!/usr/bin/env lua
-- Simple JSON benchmark.
--
-- Your Mileage May Vary.
--
-- Mark Pulford <mark@kyne.com.au>
require "common"
local json = require "cjson"
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
for i = 1, #arg do
local results = bench_file(arg[i])
for k, v in pairs(results) do
print(string.format("%s: %s: %d", arg[i], k, v))
end
end
-- vi:ai et sw=4 ts=4:
|