diff options
Diffstat (limited to 'performance.adoc')
-rw-r--r-- | performance.adoc | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/performance.adoc b/performance.adoc new file mode 100644 index 0000000..a36412d --- /dev/null +++ b/performance.adoc | |||
@@ -0,0 +1,89 @@ | |||
1 | JSON module performance comparison under Lua | ||
2 | ============================================ | ||
3 | Mark Pulford <mark@kyne.com.au> | ||
4 | :revdate: January 22, 2012 | ||
5 | |||
6 | This performance comparison aims to provide a guide of relative | ||
7 | performance between several fast and popular JSON modules. | ||
8 | |||
9 | The examples used in this comparison were mostly sourced from the | ||
10 | http://json.org[JSON website] and | ||
11 | http://tools.ietf.org/html/rfc4627[RFC 4627]. | ||
12 | |||
13 | Performance will vary widely between platforms and data sets. These | ||
14 | results should only be used as an approximation. | ||
15 | |||
16 | |||
17 | Modules | ||
18 | ------- | ||
19 | |||
20 | The following JSON modules for Lua were tested: | ||
21 | |||
22 | http://chiselapp.com/user/dhkolf/repository/dkjson/[DKJSON 2.1]:: | ||
23 | - Lua implementation with no dependencies on other libraries | ||
24 | - Supports LPeg to improve decode performance | ||
25 | |||
26 | https://github.com/brimworks/lua-yajl[Lua YAJL 2.0]:: | ||
27 | - C wrapper for the YAJL library | ||
28 | |||
29 | http://www.kyne.com.au/%7Emark/software/lua-cjson.php[Lua CJSON 2.0.0]:: | ||
30 | - C implementation with no dependencies on other libraries | ||
31 | |||
32 | |||
33 | Summary | ||
34 | ------- | ||
35 | |||
36 | All modules were built and tested as follows: | ||
37 | |||
38 | DKJSON:: Tested with/without LPeg 10.2. | ||
39 | Lua YAJL:: Tested with YAJL 2.0.4. | ||
40 | Lua CJSON:: Tested with Libc and internal floating point conversion | ||
41 | routines. | ||
42 | |||
43 | The following Lua implementations were used for this comparison: | ||
44 | |||
45 | - http://www.lua.org[Lua 5.1.4] (_Lua_) | ||
46 | - http://www.luajit.org[LuaJIT 2.0.0-beta9] (_JIT_) | ||
47 | |||
48 | These results show the number of JSON operations per second sustained by | ||
49 | each module. All results have been normalised against the pure Lua | ||
50 | DKJSON implementation. | ||
51 | |||
52 | .Decoding performance | ||
53 | ............................................................................ | ||
54 | | DKJSON | Lua YAJL | Lua CJSON | ||
55 | | No LPeg With LPeg | | Libc Internal | ||
56 | | Lua JIT Lua JIT | Lua JIT | Lua JIT Lua JIT | ||
57 | example1 | 1x 2x 2.6x 3.4x | 7.1x 10x | 14x 20x 14x 20x | ||
58 | example2 | 1x 2.2x 2.9x 4.4x | 6.7x 9.9x | 14x 22x 14x 22x | ||
59 | example3 | 1x 2.1x 3x 4.3x | 6.9x 9.3x | 14x 21x 15x 22x | ||
60 | example4 | 1x 2x 2.5x 3.7x | 7.3x 10x | 12x 19x 12x 20x | ||
61 | example5 | 1x 2.2x 3x 4.5x | 7.8x 11x | 16x 24x 16x 24x | ||
62 | numbers | 1x 2.2x 2.3x 4x | 4.6x 5.5x | 8.9x 10x 13x 17x | ||
63 | rfc-example1 | 1x 2.1x 2.8x 4.3x | 6.1x 8.1x | 13x 19x 14x 21x | ||
64 | rfc-example2 | 1x 2.1x 3.1x 4.2x | 7.1x 9.2x | 15x 21x 17x 24x | ||
65 | types | 1x 2.2x 2.6x 4.3x | 5.3x 7.4x | 12x 20x 13x 21x | ||
66 | -------------|-------------------------|------------|----------------------- | ||
67 | = Average => | 1x 2.1x 2.7x 4.1x | 6.5x 9x | 13x 20x 14x 21x | ||
68 | ............................................................................ | ||
69 | |||
70 | .Encoding performance | ||
71 | ............................................................................. | ||
72 | | DKJSON | Lua YAJL | Lua CJSON | ||
73 | | No LPeg With LPeg | | Libc Internal | ||
74 | | Lua JIT Lua JIT | Lua JIT | Lua JIT Lua JIT | ||
75 | example1 | 1x 1.8x 0.97x 1.6x | 3.1x 5.2x | 23x 29x 23x 29x | ||
76 | example2 | 1x 2x 0.97x 1.7x | 2.6x 4.3x | 22x 28x 22x 28x | ||
77 | example3 | 1x 1.9x 0.98x 1.6x | 2.8x 4.3x | 13x 15x 16x 18x | ||
78 | example4 | 1x 1.7x 0.96x 1.3x | 3.9x 6.1x | 15x 19x 17x 21x | ||
79 | example5 | 1x 2x 0.98x 1.7x | 2.7x 4.5x | 20x 23x 20x 23x | ||
80 | numbers | 1x 2.3x 1x 2.2x | 1.3x 1.9x | 3.8x 4.1x 4.2x 4.6x | ||
81 | rfc-example1 | 1x 1.9x 0.97x 1.6x | 2.2x 3.2x | 8.5x 9.3x 11x 12x | ||
82 | rfc-example2 | 1x 1.9x 0.98x 1.6x | 2.6x 3.9x | 10x 11x 17x 19x | ||
83 | types | 1x 2.2x 0.97x 2x | 1.2x 1.9x | 11x 13x 12x 14x | ||
84 | -------------|-------------------------|------------|----------------------- | ||
85 | = Average => | 1x 1.9x 0.98x 1.7x | 2.5x 3.9x | 14x 17x 16x 19x | ||
86 | ............................................................................. | ||
87 | |||
88 | |||
89 | // vi:ft=asciidoc tw=72: | ||