diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 16 | ||||
-rw-r--r-- | lua-cjson.spec | 3 | ||||
-rw-r--r-- | performance.txt | 106 |
4 files changed, 74 insertions, 53 deletions
@@ -1,6 +1,6 @@ | |||
1 | *.html | ||
1 | *.o | 2 | *.o |
2 | *.so | 3 | *.so |
3 | manual.html | ||
4 | notes | 4 | notes |
5 | packages | 5 | packages |
6 | tags | 6 | tags |
@@ -73,19 +73,26 @@ TEST_FILES = README bench.lua genutf8.pl test.lua octets-escaped.dat \ | |||
73 | DATAPERM = 644 | 73 | DATAPERM = 644 |
74 | EXECPERM = 755 | 74 | EXECPERM = 755 |
75 | 75 | ||
76 | ASCIIDOC ?= asciidoc | ||
77 | |||
76 | BUILD_CFLAGS = -I$(LUA_INCLUDE_DIR) $(CJSON_CFLAGS) | 78 | BUILD_CFLAGS = -I$(LUA_INCLUDE_DIR) $(CJSON_CFLAGS) |
77 | FPCONV_OBJS ?= fpconv.o | 79 | FPCONV_OBJS ?= fpconv.o |
78 | OBJS := lua_cjson.o strbuf.o $(FPCONV_OBJS) | 80 | OBJS := lua_cjson.o strbuf.o $(FPCONV_OBJS) |
79 | 81 | ||
80 | .PHONY: all clean install install-extra doc | 82 | .PHONY: all clean install install-extra doc |
81 | 83 | ||
82 | all: $(TARGET) | 84 | .SUFFIXES: .html .txt |
83 | |||
84 | doc: manual.html | ||
85 | 85 | ||
86 | .c.o: | 86 | .c.o: |
87 | $(CC) -c $(CFLAGS) $(CPPFLAGS) $(BUILD_CFLAGS) -o $@ $< | 87 | $(CC) -c $(CFLAGS) $(CPPFLAGS) $(BUILD_CFLAGS) -o $@ $< |
88 | 88 | ||
89 | .txt.html: | ||
90 | $(ASCIIDOC) -n -a toc $< | ||
91 | |||
92 | all: $(TARGET) | ||
93 | |||
94 | doc: manual.html performance.html | ||
95 | |||
89 | $(TARGET): $(OBJS) | 96 | $(TARGET): $(OBJS) |
90 | $(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS) | 97 | $(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS) |
91 | 98 | ||
@@ -106,8 +113,5 @@ install-extra: | |||
106 | cd tests; cp $(TEST_FILES) $(DESTDIR)/$(LUA_MODULE_DIR)/cjson/tests | 113 | cd tests; cp $(TEST_FILES) $(DESTDIR)/$(LUA_MODULE_DIR)/cjson/tests |
107 | cd tests; chmod $(DATAPERM) $(TEST_FILES); chmod $(EXECPERM) *.lua *.pl | 114 | cd tests; chmod $(DATAPERM) $(TEST_FILES); chmod $(EXECPERM) *.lua *.pl |
108 | 115 | ||
109 | manual.html: manual.txt | ||
110 | asciidoc -n -a toc manual.txt | ||
111 | |||
112 | clean: | 116 | clean: |
113 | rm -f *.o $(TARGET) | 117 | rm -f *.o $(TARGET) |
diff --git a/lua-cjson.spec b/lua-cjson.spec index 108651c..8f53671 100644 --- a/lua-cjson.spec +++ b/lua-cjson.spec | |||
@@ -50,8 +50,7 @@ rm -rf "$RPM_BUILD_ROOT" | |||
50 | 50 | ||
51 | %files | 51 | %files |
52 | %defattr(-,root,root,-) | 52 | %defattr(-,root,root,-) |
53 | %doc LICENSE NEWS performance.txt manual.html manual.txt rfc4627.txt THANKS | 53 | %doc LICENSE NEWS performance.html performance.txt manual.html manual.txt rfc4627.txt THANKS |
54 | %{_bindir}/* | ||
55 | %{lualibdir}/* | 54 | %{lualibdir}/* |
56 | %{luadatadir}/* | 55 | %{luadatadir}/* |
57 | %{_bindir}/* | 56 | %{_bindir}/* |
diff --git a/performance.txt b/performance.txt index 51c61ec..dd0872e 100644 --- a/performance.txt +++ b/performance.txt | |||
@@ -1,51 +1,69 @@ | |||
1 | JSON Performance Comparison under Lua | 1 | JSON performance under Lua |
2 | ------------------------------------- | 2 | ========================== |
3 | 3 | ||
4 | The following JSON packages for Lua were tested: | 4 | Modules |
5 | ------- | ||
5 | 6 | ||
6 | - DKJSON 1.0: One of the fastest pure Lua JSON implementations. | 7 | The following fast JSON libraries for Lua were tested: |
7 | - LuaJSON 1.0: A mixed Lua/C JSON implementation using LPeg. | ||
8 | - Lua YAJL 2.0: A Lua wrapper for the YAJL JSON library. | ||
9 | - CSJON 1.0.2: Pure C. | ||
10 | 8 | ||
11 | LuaJSON 1.2.2 appeared to be slower during initial testing, so 1.0 was | 9 | [horizontal] |
12 | used instead. | 10 | http://chiselapp.com/user/dhkolf/repository/dkjson/[DKJSON 2.1]:: |
11 | - A Lua implementation with no dependencies | ||
12 | - Also supports LPeg to improve decode performance | ||
13 | - Tested with/without LPeg 10.2 | ||
14 | https://github.com/brimworks/lua-yajl[Lua YAJL 2.0]:: | ||
15 | - A C wrapper for the YAJL library | ||
16 | - Built with YAJL 2.0.4 | ||
17 | http://www.kyne.com.au/~mark/software/lua-cjson.php[Lua CSJON 2.0.0]:: | ||
18 | - A C implementation with no dependencies on other libraries | ||
19 | - Tested with/without internal floating point conversion routines | ||
13 | 20 | ||
14 | The following Lua implementations were used for this comparison: | 21 | The following Lua implementations were used for this comparison: |
15 | - Lua 5.1.4 | 22 | |
16 | - LuaJIT 2.0.0-beta7 | 23 | - http://www.lua.org[Lua 5.1.4] |
17 | 24 | - http://www.luajit.org[LuaJIT 2.0.0-beta9] | |
18 | The example JSON files used were taken from http://json.org/ and | 25 | |
19 | RFC 4627. | 26 | |
20 | 27 | Summary | |
21 | DKJSON 1.0 LuaJSON 1.0 LuaYAJL 2.0 CJSON 1.0.2 | 28 | ------- |
22 | == Decoding == Lua LuaJIT Lua LuaJIT Lua LuaJIT Lua LuaJIT | 29 | |
23 | example1 1.0x 2.0x 3.4x 4.0x 7.1x 10.1x 13.2x 19.4x | 30 | All libraries were built and used with their default settings. |
24 | example2 1.0x 2.1x 3.5x 4.5x 6.6x 9.8x 12.7x 20.0x | 31 | |
25 | example3 1.0x 2.0x 3.9x 4.7x 7.0x 9.4x 13.2x 19.3x | 32 | These results represent the number of JSON operations per second |
26 | example4 1.0x 1.9x 3.7x 4.4x 7.4x 10.6x 11.8x 18.0x | 33 | sustained by each module. All the results have been normalised against |
27 | example5 1.0x 2.1x 4.0x 4.7x 7.7x 11.4x 14.7x 22.3x | 34 | the pure Lua DKSJON implementation. |
28 | numbers 1.0x 2.1x 2.1x 3.4x 4.6x 5.7x 8.6x 10.4x | 35 | |
29 | rfc-example1 1.0x 2.0x 3.2x 4.2x 5.8x 8.2x 11.8x 17.7x | 36 | .Decoding performance |
30 | rfc-example2 1.0x 2.0x 3.6x 4.5x 7.0x 9.3x 14.5x 20.5x | 37 | ............................................................................ |
31 | types 1.0x 2.1x 2.3x 3.5x 4.9x 7.6x 10.7x 17.2x | 38 | | DKJSON +LPeg | Lua YAJL | Lua CJSON +fpconv |
32 | == Average ==> 1.0x 2.0x 3.3x 4.2x 6.4x 9.1x 12.4x 18.3x | 39 | | Lua JIT Lua JIT | Lua JIT | Lua JIT Lua JIT |
33 | 40 | example1 | 1x 2x 2.6x 3.4x | 7.1x 10x | 14x 20x 14x 20x | |
34 | == Encoding == | 41 | example2 | 1x 2.2x 2.9x 4.4x | 6.7x 9.9x | 14x 22x 14x 22x |
35 | example1 1.0x 1.9x 0.6x 1.4x 3.5x 5.6x 23.1x 29.1x | 42 | example3 | 1x 2.1x 3x 4.3x | 6.9x 9.3x | 14x 21x 15x 22x |
36 | example2 1.0x 2.0x 0.5x 1.2x 3.0x 4.9x 23.4x 28.5x | 43 | example4 | 1x 2x 2.5x 3.7x | 7.3x 10x | 12x 19x 12x 20x |
37 | example3 1.0x 1.8x 0.6x 1.3x 3.0x 4.7x 13.3x 14.9x | 44 | example5 | 1x 2.2x 3x 4.5x | 7.8x 11x | 16x 24x 16x 24x |
38 | example4 1.0x 1.7x 0.7x 1.5x 4.2x 6.6x 15.4x 18.5x | 45 | numbers | 1x 2.2x 2.3x 4x | 4.6x 5.5x | 8.9x 10x 13x 17x |
39 | example5 1.0x 2.0x 0.6x 1.4x 3.4x 5.5x 22.7x 25.5x | 46 | rfc-example1 | 1x 2.1x 2.8x 4.3x | 6.1x 8.1x | 13x 19x 14x 21x |
40 | numbers 1.0x 2.4x 0.4x 0.9x 1.4x 2.1x 4.3x 4.6x | 47 | rfc-example2 | 1x 2.1x 3.1x 4.2x | 7.1x 9.2x | 15x 21x 17x 24x |
41 | rfc-example1 1.0x 1.9x 0.5x 1.2x 2.3x 3.6x 8.8x 9.6x | 48 | types | 1x 2.2x 2.6x 4.3x | 5.3x 7.4x | 12x 20x 13x 21x |
42 | rfc-example2 1.0x 1.9x 0.6x 1.3x 2.8x 4.3x 10.7x 10.7x | 49 | = Average => | 1x 2.1x 2.7x 4.1x | 6.5x 9x | 13x 20x 14x 21x |
43 | types 1.0x 2.4x 0.3x 0.7x 1.4x 2.3x 11.7x 11.3x | 50 | ............................................................................ |
44 | == Average ==> 1.0x 2.0x 0.6x 1.2x 2.8x 4.4x 14.8x 17.0x | 51 | |
45 | 52 | .Encoding performance | |
46 | 53 | ............................................................................. | |
47 | Number conversion is a relatively expensive operation. Number heavy | 54 | | DKJSON +LPeg | Lua YAJL | Lua CJSON +fpconv |
48 | JSON will show less performance difference between libraries. | 55 | | Lua JIT Lua JIT | Lua JIT | Lua JIT Lua JIT |
56 | example1 | 1x 1.8x 0.97x 1.6x | 3.1x 5.2x | 23x 29x 23x 29x | ||
57 | example2 | 1x 2x 0.97x 1.7x | 2.6x 4.3x | 22x 28x 22x 28x | ||
58 | example3 | 1x 1.9x 0.98x 1.6x | 2.8x 4.3x | 13x 15x 16x 18x | ||
59 | example4 | 1x 1.7x 0.96x 1.3x | 3.9x 6.1x | 15x 19x 17x 21x | ||
60 | example5 | 1x 2x 0.98x 1.7x | 2.7x 4.5x | 20x 23x 20x 23x | ||
61 | numbers | 1x 2.3x 1x 2.2x | 1.3x 1.9x | 3.8x 4.1x 4.2x 4.6x | ||
62 | rfc-example1 | 1x 1.9x 0.97x 1.6x | 2.2x 3.2x | 8.5x 9.3x 11x 12x | ||
63 | rfc-example2 | 1x 1.9x 0.98x 1.6x | 2.6x 3.9x | 10x 11x 17x 19x | ||
64 | types | 1x 2.2x 0.97x 2x | 1.2x 1.9x | 11x 13x 12x 14x | ||
65 | = Average => | 1x 1.9x 0.98x 1.7x | 2.5x 3.9x | 14x 17x 16x 19x | ||
66 | ............................................................................. | ||
49 | 67 | ||
50 | Performance can vary widely between platforms and data sets. These | 68 | Performance can vary widely between platforms and data sets. These |
51 | results should only be considered as a rough guide. | 69 | results should only be used as a rough guide. |