aboutsummaryrefslogtreecommitdiff
path: root/tests/bench.lua
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2011-05-08 02:23:57 +0930
committerMark Pulford <mark@kyne.com.au>2011-05-08 02:23:57 +0930
commit0d56e3bebecb7008f0baa7eaccf3dc9b2a39e360 (patch)
tree8c15c63f01afa79115f2b66b922bb27779df9b90 /tests/bench.lua
parent3d014d14bcf3dce3e5dbb9c193d689e46d333798 (diff)
downloadlua-cjson-0d56e3bebecb7008f0baa7eaccf3dc9b2a39e360.tar.gz
lua-cjson-0d56e3bebecb7008f0baa7eaccf3dc9b2a39e360.tar.bz2
lua-cjson-0d56e3bebecb7008f0baa7eaccf3dc9b2a39e360.zip
Implement data driven test framework
- Add run_test(): Test a function and verify its output - Add run_test_group(): Execute a test batch - Add serialise_value(): Serialise a Lua value into the Lua syntax - Add file_save() helper function - Add NaN comparison support to compare_values()
Diffstat (limited to 'tests/bench.lua')
-rwxr-xr-xtests/bench.lua15
1 files changed, 7 insertions, 8 deletions
diff --git a/tests/bench.lua b/tests/bench.lua
index b5b1a77..847365b 100755
--- a/tests/bench.lua
+++ b/tests/bench.lua
@@ -3,11 +3,11 @@
3-- Simple JSON benchmark. 3-- Simple JSON benchmark.
4-- 4--
5-- Your Mileage May Vary. 5-- Your Mileage May Vary.
6--
7-- Mark Pulford <mark@kyne.com.au>
6 8
7require "common" 9require "common"
8local json = require "cjson" 10local json = require "cjson"
9--local json = require "json"
10--local json = require "dkjson"
11 11
12function bench_file(filename) 12function bench_file(filename)
13 local data_json = file_load(filename) 13 local data_json = file_load(filename)
@@ -28,12 +28,11 @@ function bench_file(filename)
28 return benchmark(tests, 5000, 5) 28 return benchmark(tests, 5000, 5)
29end 29end
30 30
31i = 1 31for i = 1, #arg do
32while arg[i] do 32 local results = bench_file(arg[i])
33 local results = {} 33 for k, v in pairs(results) do
34 results[arg[i]] = bench_file(arg[i]) 34 print(string.format("%s: %s: %d", arg[i], k, v))
35 dump_value(results) 35 end
36 i = i + 1
37end 36end
38 37
39-- vi:ai et sw=4 ts=4: 38-- vi:ai et sw=4 ts=4: