performance.txt 4.0 KB

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