Skip to content

Commit

Permalink
JSON Benchmark: Add
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Sep 26, 2020
1 parent 559198e commit bbd22d5
Show file tree
Hide file tree
Showing 10 changed files with 428 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
known_third_party = Image,PIL,PyPDF2,PyPDF2Highlight,Pyro,Pyro4,Queue,analysis,app,autokeras,autosklearn,bibtexparser,black,blacken_docs,bs4,cairocffi,cifar10,cifar10_input,clana,click,cv2,dask,dblp_parser,densenet,editdistance,exampleproject,external_dependency,factorize,faker,fitz,flask,flask_babel,flask_login,flask_mail,flask_sqlalchemy,flask_wtf,grapheme,gtsdb,gtsrb,gym,gym_banana,h5py,hasy,hasy_tools,hog_features,hypothesis,image_ocr,imageio,implicit,input_data,javarandom,jinja2,keras,locust,lxml,math_functions,matplotlib,mini_app,mnist,mock_example,mpl_toolkits,mpu,msgpack,natsort,networkx,nltk,numpy,orms,orms2,package_analysis,pandas,pdfminer,progressbar,pydantic,pygame,pygtrie,pylab,pympler,pymysql,pypika,pyspark,pytest,pythonwhois,randomgen,raw_sql,red_black_tree,redis,reportlab,requests,requests_example,responses,reuters,rl,rl_utils,scipy,scoring,seaborn,sequential_model,six,skflow,skimage,sklearn,sqlalchemy,ssd,ssd_layers,ssd_utils,surprise,tensorflow,textract,tflearn,toml,tqdm,tsne,ujson,urllib2,utils,visualize,werkzeug,wikicommons,wtforms,xgboost,xmltodict,yaml
known_third_party = Image,PIL,PyPDF2,PyPDF2Highlight,Pyro,Pyro4,Queue,analysis,app,autokeras,autosklearn,bibtexparser,black,blacken_docs,bs4,cairocffi,cifar10,cifar10_input,clana,click,cv2,dask,dblp_parser,densenet,editdistance,exampleproject,external_dependency,factorize,faker,fitz,flask,flask_babel,flask_login,flask_mail,flask_sqlalchemy,flask_wtf,grapheme,gtsdb,gtsrb,gym,gym_banana,h5py,hasy,hasy_tools,hog_features,hypothesis,image_ocr,imageio,implicit,input_data,javarandom,jinja2,keras,locust,lxml,math_functions,matplotlib,mini_app,mnist,mock_example,mpl_toolkits,mpu,msgpack,natsort,networkx,nltk,numpy,orjson,orms,orms2,package_analysis,pandas,pdfminer,progressbar,pydantic,pygame,pygtrie,pylab,pympler,pymysql,pypika,pyspark,pytest,pythonwhois,randomgen,rapidjson,raw_sql,red_black_tree,redis,reportlab,requests,requests_example,responses,reuters,rl,rl_utils,scipy,scoring,seaborn,sequential_model,simdjson,simplejson,six,skflow,skimage,sklearn,sqlalchemy,ssd,ssd_layers,ssd_utils,surprise,tensorflow,textract,tflearn,toml,tqdm,tsne,ujson,urllib2,utils,visualize,werkzeug,wikicommons,wtforms,xgboost,xmltodict,yaml
1 change: 1 addition & 0 deletions Python/json-benchmark/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8.6
214 changes: 214 additions & 0 deletions Python/json-benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
# Comparison of JSON packages in Python

Python has a couple of packages which parse / dump JSON for you. Here is a
comparison of them. The dates are as of 2020-09-26 07:00+00:00:

<table>
<tr>
<th></th>
<th>cPython JSON</th>
<th>simplejson</th>
<th>ujson</th>
<th>orjson</th>
<th>pysimdjson</th>
<th>python-rapidjson</th>
</tr>
<tr>
<th>License</th>
<td>Python Software Foundation License</td>
<td>MIT / Academic Free License (AFL)</td>
<td>BSD License</td>
<td>MIT / Apache</td>
<td>MIT</td>
<td>MIT</td>
</tr>
<tr>
<th colspan="7">Maturity</th>
</tr>
<tr>
<th>Version</th>
<td>3.8.6</td>
<td>3.17.2</td>
<td>3.2.0</td>
<td>3.4.0</td>
<td>3.0.0</td>
<td>0.9.1</td>
</tr>
<tr>
<th>Development Status</th>
<td></td>
<td>Production/Stable</td>
<td>Production/Stable</td>
<td>Production/Stable</td>
<td style="background-color: red;">Alpha</td>
<td style="background-color: red;">Alpha</td>
</tr>
<tr>
<th>GH First release</th>
<td><span alt="v0.9.8">1993-01-10</span></td>
<td><span alt="v1.1">2006-01-01</span></td>
<td><span alt="v1.19">2012-06-18</span></td>
<td><span alt="1.0.0">2018-11-23</span></td>
<td><span alt="v1.2.0">2019-02-23</span></td>
<td><span alt="v0.0.9">2017-03-02</span></td>
</tr>
<tr>
<th>CI-Pipeline</th>
<td>GH, Travis, Azure</td>
<td>GH, Travis, Appveyor</td>
<td>GH, Travis</td>
<td>Azure</td>
<td>GH, Travis</td>
<td>Appveyor</td>
</tr>
<tr>
<th colspan="7">Operational Safety</th>
</tr>
<tr>
<th>GH Organization</th>
<td>✓</td>
<td>✓</td>
<td>✓</td>
<td>✗</td>
<td>✗</td>
<td>✓</td>
</tr>
<tr>
<th>GH Contributors</th>
<td>1319</td>
<td>30</td>
<td>50</td>
<td>9</td>
<td>7</td>
<td>15</td>
</tr>
<tr>
<th>Last release</th>
<td>2020-09-23</td>
<td>2020-07-16</td>
<td>2020-09-08</td>
<td>2020-09-25</td>
<td>2020-08-21</td>
<td>2019-11-13</td>
</tr>
<tr>
<th>Last Commit</th>
<td>2020-09-25</td>
<td>2020-07-16</td>
<td>2020-09-19</td>
<td>2020-09-25</td>
<td>2020-08-31</td>
<td>2020-05-08</td>
</tr>
<tr>
<th>PyPI Maintainers</th>
<td></td>
<td>3</td>
<td>4</td>
<td style="background-color: red;">1</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<th colspan="7">Users</th>
</tr>
<tr>
<th>GH Stars</th>
<td>33,700</td>
<td>1310</td>
<td>2966</td>
<td>1348</td>
<td>374</td>
<td>397</td>
</tr>
<tr>
<th>GH Forks</th>
<td>16,200</td>
<td>290</td>
<td>306</td>
<td>48</td>
<td>25</td>
<td>31</td>
</tr>
<tr>
<th>GH Used By</th>
<td>-</td>
<td>47,164</td>
<td>14,760</td>
<td>613</td>
<td>11</td>
<td>661</td>
</tr>
<tr>
<th>StackOverflow Questions</th>
<td></td>
<td><a href="https://stackoverflow.com/questions/tagged/simplejson">279</a></td>
<td><a href="https://stackoverflow.com/questions/tagged/ujson">6</a></td>
<td><a href="https://stackoverflow.com/questions/tagged/orjson">3</a></td>
<td>-</td>
<td><a href="https://stackoverflow.com/questions/tagged/rapidjson">319</a></td>
</tr>
<tr>
<th colspan="7">Benchmarks</th>
</tr>
<tr>
<th>GeoJSON Read</th>
<td>44ms</td>
<td>44ms</td>
<td style="background-color: green;">20ms</td>
<td style="background-color: green;">14ms</td>
<td style="background-color: green;">16ms</td>
<td style="background-color: red;">79ms</td>
</tr>
<tr>
<th>GeoJSON Write</th>
<td>293ms</td>
<td>364ms</td>
<td style="background-color: green;">36ms</td>
<td style="background-color: green;">15ms</td>
<td>286ms</td>
<td style="background-color: green;">106ms</td>
</tr>
<tr>
<th>Twitter Read</th>
<td>5ms</td>
<td>6ms</td>
<td>6ms</td>
<td>5ms</td>
<td>6ms</td>
<td style="background-color: red;">9ms</td>
</tr>
<tr>
<th>Twitter Write</th>
<td>24ms</td>
<td>30ms</td>
<td style="background-color: green;">5ms</td>
<td style="background-color: green;">3ms</td>
<td>24ms</td>
<td style="background-color: green;">7ms</td>
</tr>
</table>

## Speed Plots

* The baseline for reading is just reading the text file as text.
* The baseline for writing is dumping the JSON as text (converted to text before)

### GeoJSON

![](geojson-read.png)
![](geojson-write.png)

### Twitter

![](twitter-read.png)
![](twitter-write.png)

## Links

* [cPython](https://github.com/python/cpython/tags)
* [simplejson](https://pypi.org/project/simplejson/) / [GitHub](https://github.com/simplejson/simplejson)
* [ujson](https://pypi.org/project/ujson/) / [GitHub](https://github.com/ultrajson/ultrajson)
* [orjson](https://pypi.org/project/orjson/) / [GitHub](https://github.com/ijl/orjson)
* [pysimdjson](https://pypi.org/project/pysimdjson/) / [GitHub](https://github.com/TkTech/pysimdjson)
* [python-rapidjson](https://pypi.org/project/python-rapidjson/) / [GitHub](https://github.com/python-rapidjson/python-rapidjson)
1 change: 1 addition & 0 deletions Python/json-benchmark/data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The data was taken from https://github.com/serde-rs/json-benchmark/tree/master/data
Binary file added Python/json-benchmark/geojson-read.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Python/json-benchmark/geojson-write.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions Python/json-benchmark/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
simplejson==3.17.2
ujson==3.2.0
orjson==3.4.0
pysimdjson==3.0.0
python-rapidjson==0.9.1

seaborn
numpy
matplotlib
Loading

0 comments on commit bbd22d5

Please sign in to comment.