diff options
| author | Mark Pulford <mark@kyne.com.au> | 2011-05-08 02:23:57 +0930 |
|---|---|---|
| committer | Mark Pulford <mark@kyne.com.au> | 2011-05-08 02:23:57 +0930 |
| commit | 0d56e3bebecb7008f0baa7eaccf3dc9b2a39e360 (patch) | |
| tree | 8c15c63f01afa79115f2b66b922bb27779df9b90 /tests/bench.lua | |
| parent | 3d014d14bcf3dce3e5dbb9c193d689e46d333798 (diff) | |
| download | lua-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 '')
| -rwxr-xr-x | tests/bench.lua | 15 |
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 | ||
| 7 | require "common" | 9 | require "common" |
| 8 | local json = require "cjson" | 10 | local json = require "cjson" |
| 9 | --local json = require "json" | ||
| 10 | --local json = require "dkjson" | ||
| 11 | 11 | ||
| 12 | function bench_file(filename) | 12 | function 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) |
| 29 | end | 29 | end |
| 30 | 30 | ||
| 31 | i = 1 | 31 | for i = 1, #arg do |
| 32 | while 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 | ||
| 37 | end | 36 | end |
| 38 | 37 | ||
| 39 | -- vi:ai et sw=4 ts=4: | 38 | -- vi:ai et sw=4 ts=4: |
