1
0
mirror of https://github.com/ultrajson/ultrajson.git synced 2024-11-24 05:12:02 +01:00

Reverted markdown README with completly incorrect benchmark values

This commit is contained in:
Jonas Trnstrm 2012-01-27 11:06:56 +01:00
parent 1a3afc64ce
commit ce5ac1e5dc
2 changed files with 221 additions and 119 deletions

221
README Normal file

@ -0,0 +1,221 @@
UltraJSON is a fast and extendable JSON encoder and decoder written in pure C
Python bindings are available as the module ujson (through easy_install / pypi):
http://pypi.python.org/pypi/ujson/
Installation instructions:
1. Build and install ujson Python extension (requires root)
Go to <root>/python
Type: python setup.py build install
2. Run tests (as needed)
Type: python tests.py
Same instructions applies for Windows except that step 1) isn't necessary since
a prebuilt static library is included.
Preliminary benchmarks:
64-bit benchmarks Linux
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
OS Version: Ubuntu 10.10
System Type: x64-based PC
Processor: Intel(R) Core(TM) i5-2300 CPU @ 2.80GHz
Total Physical Memory: 4096 MB
Array with 256 utf-8 strings:
ujson encode : 2714.66499 calls/sec
simplejson encode : 1542.63718 calls/sec
cjson encode : 132.23604 calls/sec
ujson decode : 2079.17287 calls/sec
cjson decode : 992.21602 calls/sec
simplejson decode : 278.92061 calls/sec
Medium complex object:
ujson encode : 17849.80356 calls/sec
simplejson encode : 3524.32372 calls/sec
cjson encode : 2967.34656 calls/sec
ujson decode : 11685.87610 calls/sec
cjson decode : 8206.67906 calls/sec
simplejson decode : 6549.99750 calls/sec
Array with 256 strings:
ujson encode : 38543.50303 calls/sec
simplejson encode : 19436.45772 calls/sec
cjson encode : 12392.55614 calls/sec
ujson decode : 27207.33157 calls/sec
cjson decode : 30237.60827 calls/sec
simplejson decode : 25271.93073 calls/sec
Array with 256 doubles:
ujson encode : 6027.45931 calls/sec
simplejson encode : 2915.54871 calls/sec
cjson encode : 3546.88804 calls/sec
ujson decode : 28045.13375 calls/sec
cjson decode : 15066.73209 calls/sec
simplejson decode : 15604.98222 calls/sec
Array with 256 True values:
ujson encode : 187342.39634 calls/sec
simplejson encode : 48972.93887 calls/sec
cjson encode : 67274.93082 calls/sec
ujson decode : 158103.79663 calls/sec
cjson decode : 83237.88990 calls/sec
simplejson decode : 115645.98241 calls/sec
Array with 256 dict{string, int} pairs:
ujson encode : 25301.85690 calls/sec
simplejson encode : 5734.29472 calls/sec
cjson encode : 4447.73411 calls/sec
ujson decode : 16290.72288 calls/sec
cjson decode : 12528.56060 calls/sec
simplejson decode : 10394.23358 calls/sec
Dict with 256 arrays with 256 dict{string, int} pairs:
ujson encode : 87.40865 calls/sec
simplejson encode : 17.07889 calls/sec
cjson encode : 17.25164 calls/sec
ujson decode : 45.94026 calls/sec
cjson decode : 34.60225 calls/sec
simplejson decode : 26.92238 calls/sec
32-bit benchmarks Windows
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
OS Version: 6.1.7601 Service Pack 1 Build 7601
System Type: x64-based PC
Processor: Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz 2.83 GHz
Total Physical Memory: 8191 MB
Array with 256 utf-8 strings:
ujson encode : 1191.98175 calls/sec
simplejson encode : 1013.98279 calls/sec
cjson encode : 1040.66063 calls/sec
ujson decode : 1215.66875 calls/sec
cjson decode : 493.30484 calls/sec
simplejson decode : 269.85512 calls/sec
Medium complex object:
ujson encode : 10307.63723 calls/sec
simplejson encode : 2534.94769 calls/sec
cjson encode : 2047.95118 calls/sec
ujson decode : 7274.10026 calls/sec
cjson decode : 3575.39307 calls/sec
simplejson decode : 3565.51252 calls/sec
Array with 256 strings:
ujson encode : 21348.25210 calls/sec
simplejson encode : 15736.74638 calls/sec
cjson encode : 6371.26334 calls/sec
ujson decode : 26050.25316 calls/sec
cjson decode : 16468.88215 calls/sec
simplejson decode : 21115.75770 calls/sec
Array with 256 doubles:
ujson encode : 26975.49110 calls/sec
simplejson encode : 2046.29746 calls/sec
cjson encode : 2133.56594 calls/sec
ujson decode : 28430.33722 calls/sec
cjson decode : 4114.36400 calls/sec
simplejson decode : 4419.08507 calls/sec
Array with 256 True values:
ujson encode : 89846.12897 calls/sec
simplejson encode : 34288.36862 calls/sec
cjson encode : 47168.35849 calls/sec
ujson decode : 99423.47549 calls/sec
cjson decode : 58795.91460 calls/sec
simplejson decode : 76296.14699 calls/sec
Array with 256 dict{string, int} pairs:
ujson encode : 14776.41614 calls/sec
simplejson encode : 3876.86634 calls/sec
cjson encode : 3050.65343 calls/sec
ujson decode : 12934.39432 calls/sec
cjson decode : 7993.04345 calls/sec
simplejson decode : 7152.09475 calls/sec
Here is the benchmark run from a 32bit CentOS 5.6 (Python 2.4) machine:
Array with 256 utf-8 strings:
ujson encode : 1453.30891 calls/sec
simplejson encode : 658.31181 calls/sec
cjson encode : 62.18416 calls/sec
ujson decode : 1016.58767 calls/sec
cjson decode : 455.28550 calls/sec
simplejson decode : 124.20439 calls/sec
Medium complex object:
ujson encode : 6010.21634 calls/sec
simplejson encode : 1418.77823 calls/sec
cjson encode : 1252.92530 calls/sec
ujson decode : 4637.52630 calls/sec
cjson decode : 3444.13604 calls/sec
simplejson decode : 2166.18641 calls/sec
Array with 256 strings:
ujson encode : 12252.28889 calls/sec
simplejson encode : 9351.67532 calls/sec
cjson encode : 7786.13697 calls/sec
ujson decode : 10951.17394 calls/sec
cjson decode : 15971.02425 calls/sec
simplejson decode : 6796.77480 calls/sec
Array with 256 doubles:
ujson encode : 16300.61218 calls/sec
simplejson encode : 1613.39428 calls/sec
cjson encode : 2035.58937 calls/sec
ujson decode : 17301.00746 calls/sec
cjson decode : 5785.33627 calls/sec
simplejson decode : 6199.49364 calls/sec
Array with 256 True values:
ujson encode : 72618.15350 calls/sec
simplejson encode : 18707.57593 calls/sec
cjson encode : 24150.26201 calls/sec
ujson decode : 53650.94162 calls/sec
cjson decode : 48069.53050 calls/sec
simplejson decode : 47098.40293 calls/sec
Array with 256 dict{string, int} pairs:
ujson encode : 8811.85922 calls/sec
simplejson encode : 2756.91262 calls/sec
cjson encode : 1758.26962 calls/sec
ujson decode : 6490.36358 calls/sec
cjson decode : 6330.77263 calls/sec
simplejson decode : 4161.97048 calls/sec
Dict with 256 arrays with 256 dict{string, int} pairs:
ujson encode : 31.08834 calls/sec
simplejson encode : 10.41434 calls/sec
cjson encode : 6.93790 calls/sec
ujson decode : 19.81373 calls/sec
cjson decode : 20.31727 calls/sec
simplejson decode : 15.05690 calls/sec
See (python/benchmark.py) for further information.
NOTE: These benchmarks are preliminary!

119
README.md

@ -1,119 +0,0 @@
# UltraJSON
UltraJSON is a fast and extendable JSON encoder and decoder written in pure C.
As of this writing it is faster than any other mainstream JSON library available for Python.
It is part of a family of highly optimized C libraries designed to improve performance of low-level tasks. See amysql and ultramemcache.
## Installing
Currently, only bindings for Python are available (aside from the pure C library).
The easiest way to install is to use the [package available from PyPI](http://pypi.python.org/pypi/ujson/)
To install the UltraJSON Python module, run:
pip install ujson
```pip``` is very much recommended for managing Python packages. But if you don't have pip installed, try ```easy_install ujson```.
### Building
Instead of installing the packages, you may (optionally) build it from source.
Clone the project from GitHub<br>
Build and install the ujson Python extension
cd <root>/python
sudo python setup.py build install
Optionally, you can run the tests<br>
python tests.py
Same instructions applies for Windows except that step 1 isn't necessary since
a prebuilt static library is included.
## Bindings for other languages and platforms
While UltraJSON ships with Python bindings only, no assumptions has been made for the Python environment.
Porting it to other languages and platforms should be no problem. It's just that the UltraJSON developers likes and use Python on a daily basis. If you'd like to port it to Ruby, node.js or Erlang, we would be more than happy to accept such a patch.
## Performance
UltraJSON foremost design goal has been performance. By doing simple things like not iterating a single byte in buffer more than once, extreme performance has been achieved. Also, it doesn't depend on any third-party libraries
Below are 64-bit and 32-bit benchmarks, comparing UltraJSON to other popular JSON serialization libraries.
As mentioned earlier, bindings are currently only available for Python therefore these benchmarks have compared only those available in Python.
### Linux 64-bit benchmark
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
OS Version: Ubuntu 10.10
System Type: x64-based PC
Processor: Intel(R) Core(TM) i5-2300 CPU @ 2.80GHz
Total Physical Memory: 4096 MB
| Test | Type | ujson | cjson | simplejson |
|--------------------------------------------------- | ------ | --------- | --------- | ---------- |
| Medium complex object | Encode | 2534.94 | 2047.95 | 10307.63 |
| | Decode | 3565.51 | 3575.39 | 7274.10 |
| Array with 256 doubles | Encode | 2046.29 | 2133.56 | 26975.49 |
| | Decode | 4419.08 | 4114.36 | 28430.33 |
| Array with 256 strings | Encode | 15736.74 | 6371.26 | 21348.25 |
| | Decode | 21115.75 | 16468.88 | 26050.25 |
| Array with 256 dict{string, int} pairs | Encode | 3876.86 | 3050.65 | 14776.41 |
| | Decode | 7152.09 | 7993.04 | 12934.39 |
| Array with 256 utf-8 strings | Encode | 1013.98 | 1040.66 | 1191.98 |
| | Decode | 269.85 | 493.30 | 1215.66 |
| Array with 256 True values | Encode | 34288.36 | 47168.35 | 89846.12 |
| | Decode | 76296.14 | 58795.91 | 99423.47 |
### Windows 32-bit benchmark
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
OS Version: 6.1.7601 Service Pack 1 Build 7601
System Type: x64-based PC
Processor: Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz 2.83 GHz
Total Physical Memory: 8191 MB
| Test | Type | ujson | cjson | simplejson |
|--------------------------------------------------- | ------ | --------- | --------- | ---------- |
| Array with 256 utf-8 strings | Encode | 1013.98 | 1040.66 | 1191.98 |
| | Decode | 269.85 | 493.30 | 1215.66 |
| Medium complex object | Encode | 2534.94 | 2047.95 | 10307.63 |
| | Decode | 3565.51 | 3575.39 | 7274.10 |
| Array with 256 doubles | Encode | 2046.29 | 2133.56 | 26975.49 |
| | Decode | 4419.08 | 4114.36 | 28430.33 |
| Array with 256 strings | Encode | 15736.74 | 6371.26 | 21348.25 |
| | Decode | 21115.75 | 16468.88 | 26050.25 |
| Array with 256 dict{string, int} pairs | Encode | 3876.86 | 3050.65 | 14776.41 |
| | Decode | 7152.09 | 7993.04 | 12934.39 |
| Array with 256 True values | Encode | 34288.36 | 47168.35 | 89846.12 |
| | Decode | 76296.14 | 58795.91 | 99423.47 |
### Linux 32-bit benchmark
CentOS 5.6 (Python 2.4)
| Test | Type | ujson | cjson | simplejson |
|--------------------------------------------------- | ------ | --------- | --------- | ---------- |
| Dict with 256 arrays with 256 dict{string, int} pairs | Encode | 10.41 | 6.93 | 31.08 |
| | Decode | 15.05 | 20.31 | 19.81 |
| Medium complex object | Encode | 1418.77 | 1252.92 | 6010.21 |
| | Decode | 2166.18 | 3444.13 | 4637.52 |
| Array with 256 doubles | Encode | 1613.39 | 2035.58 | 16300.61 |
| | Decode | 6199.49 | 5785.33 | 17301.00 |
| Array with 256 strings | Encode | 9351.67 | 7786.13 | 12252.28 |
| | Decode | 6796.77 | 15971.02 | 10951.17 |
| Array with 256 dict{string, int} pairs | Encode | 2756.91 | 1758.26 | 8811.85 |
| | Decode | 4161.97 | 6330.77 | 6490.36 |
| Array with 256 utf-8 strings | Encode | 658.31 | 62.18 | 1453.30 |
| | Decode | 124.20 | 455.28 | 1016.58 |
| Array with 256 True values | Encode | 18707.57 | 24150.26 | 72618.15 |
| | Decode | 47098.40 | 48069.53 | 53650.94 |
See [python/benchmark.py](https://github.com/esnme/ultrajson/blob/master/python/benchmark.py) for further information.