aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile16
-rw-r--r--lua-cjson.spec3
-rw-r--r--performance.txt106
4 files changed, 74 insertions, 53 deletions
diff --git a/.gitignore b/.gitignore
index 56345ea..948a9ca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
1*.html
1*.o 2*.o
2*.so 3*.so
3manual.html
4notes 4notes
5packages 5packages
6tags 6tags
diff --git a/Makefile b/Makefile
index ac1b803..de1c144 100644
--- a/Makefile
+++ b/Makefile
@@ -73,19 +73,26 @@ TEST_FILES = README bench.lua genutf8.pl test.lua octets-escaped.dat \
73DATAPERM = 644 73DATAPERM = 644
74EXECPERM = 755 74EXECPERM = 755
75 75
76ASCIIDOC ?= asciidoc
77
76BUILD_CFLAGS = -I$(LUA_INCLUDE_DIR) $(CJSON_CFLAGS) 78BUILD_CFLAGS = -I$(LUA_INCLUDE_DIR) $(CJSON_CFLAGS)
77FPCONV_OBJS ?= fpconv.o 79FPCONV_OBJS ?= fpconv.o
78OBJS := lua_cjson.o strbuf.o $(FPCONV_OBJS) 80OBJS := 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
82all: $(TARGET) 84.SUFFIXES: .html .txt
83
84doc: 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
92all: $(TARGET)
93
94doc: 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
109manual.html: manual.txt
110 asciidoc -n -a toc manual.txt
111
112clean: 116clean:
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 @@
1JSON Performance Comparison under Lua 1JSON performance under Lua
2------------------------------------- 2==========================
3 3
4The following JSON packages for Lua were tested: 4Modules
5-------
5 6
6- DKJSON 1.0: One of the fastest pure Lua JSON implementations. 7The 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
11LuaJSON 1.2.2 appeared to be slower during initial testing, so 1.0 was 9[horizontal]
12used instead. 10http://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
14https://github.com/brimworks/lua-yajl[Lua YAJL 2.0]::
15 - A C wrapper for the YAJL library
16 - Built with YAJL 2.0.4
17http://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
14The following Lua implementations were used for this comparison: 21The 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]
18The example JSON files used were taken from http://json.org/ and 25
19RFC 4627. 26
20 27Summary
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
23example1 1.0x 2.0x 3.4x 4.0x 7.1x 10.1x 13.2x 19.4x 30All libraries were built and used with their default settings.
24example2 1.0x 2.1x 3.5x 4.5x 6.6x 9.8x 12.7x 20.0x 31
25example3 1.0x 2.0x 3.9x 4.7x 7.0x 9.4x 13.2x 19.3x 32These results represent the number of JSON operations per second
26example4 1.0x 1.9x 3.7x 4.4x 7.4x 10.6x 11.8x 18.0x 33sustained by each module. All the results have been normalised against
27example5 1.0x 2.1x 4.0x 4.7x 7.7x 11.4x 14.7x 22.3x 34the pure Lua DKSJON implementation.
28numbers 1.0x 2.1x 2.1x 3.4x 4.6x 5.7x 8.6x 10.4x 35
29rfc-example1 1.0x 2.0x 3.2x 4.2x 5.8x 8.2x 11.8x 17.7x 36.Decoding performance
30rfc-example2 1.0x 2.0x 3.6x 4.5x 7.0x 9.3x 14.5x 20.5x 37............................................................................
31types 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 40example1 | 1x 2x 2.6x 3.4x | 7.1x 10x | 14x 20x 14x 20x
34== Encoding == 41example2 | 1x 2.2x 2.9x 4.4x | 6.7x 9.9x | 14x 22x 14x 22x
35example1 1.0x 1.9x 0.6x 1.4x 3.5x 5.6x 23.1x 29.1x 42example3 | 1x 2.1x 3x 4.3x | 6.9x 9.3x | 14x 21x 15x 22x
36example2 1.0x 2.0x 0.5x 1.2x 3.0x 4.9x 23.4x 28.5x 43example4 | 1x 2x 2.5x 3.7x | 7.3x 10x | 12x 19x 12x 20x
37example3 1.0x 1.8x 0.6x 1.3x 3.0x 4.7x 13.3x 14.9x 44example5 | 1x 2.2x 3x 4.5x | 7.8x 11x | 16x 24x 16x 24x
38example4 1.0x 1.7x 0.7x 1.5x 4.2x 6.6x 15.4x 18.5x 45numbers | 1x 2.2x 2.3x 4x | 4.6x 5.5x | 8.9x 10x 13x 17x
39example5 1.0x 2.0x 0.6x 1.4x 3.4x 5.5x 22.7x 25.5x 46rfc-example1 | 1x 2.1x 2.8x 4.3x | 6.1x 8.1x | 13x 19x 14x 21x
40numbers 1.0x 2.4x 0.4x 0.9x 1.4x 2.1x 4.3x 4.6x 47rfc-example2 | 1x 2.1x 3.1x 4.2x | 7.1x 9.2x | 15x 21x 17x 24x
41rfc-example1 1.0x 1.9x 0.5x 1.2x 2.3x 3.6x 8.8x 9.6x 48types | 1x 2.2x 2.6x 4.3x | 5.3x 7.4x | 12x 20x 13x 21x
42rfc-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
43types 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.............................................................................
47Number conversion is a relatively expensive operation. Number heavy 54 | DKJSON +LPeg | Lua YAJL | Lua CJSON +fpconv
48JSON will show less performance difference between libraries. 55 | Lua JIT Lua JIT | Lua JIT | Lua JIT Lua JIT
56example1 | 1x 1.8x 0.97x 1.6x | 3.1x 5.2x | 23x 29x 23x 29x
57example2 | 1x 2x 0.97x 1.7x | 2.6x 4.3x | 22x 28x 22x 28x
58example3 | 1x 1.9x 0.98x 1.6x | 2.8x 4.3x | 13x 15x 16x 18x
59example4 | 1x 1.7x 0.96x 1.3x | 3.9x 6.1x | 15x 19x 17x 21x
60example5 | 1x 2x 0.98x 1.7x | 2.7x 4.5x | 20x 23x 20x 23x
61numbers | 1x 2.3x 1x 2.2x | 1.3x 1.9x | 3.8x 4.1x 4.2x 4.6x
62rfc-example1 | 1x 1.9x 0.97x 1.6x | 2.2x 3.2x | 8.5x 9.3x 11x 12x
63rfc-example2 | 1x 1.9x 0.98x 1.6x | 2.6x 3.9x | 10x 11x 17x 19x
64types | 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
50Performance can vary widely between platforms and data sets. These 68Performance can vary widely between platforms and data sets. These
51results should only be considered as a rough guide. 69results should only be used as a rough guide.