Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ help::

.PHONY: benchmarks
benchmarks: build
$(PYTEST) benchmarks/
PYTHONPATH=. $(PYTEST) benchmarks/

help::
@printf "benchmarks-other\n\trun the benchmarks against other engines\n"
Expand All @@ -83,12 +83,12 @@ benchmarks-others: PYTEST_OPTIONS = --compare-other-engines
benchmarks-others: benchmarks

help::
@printf "benchmarks-table\n\tproduce a reST table out of benchmarks-other results\n"
@printf "benchmarks-tables\n\tproduce a reST table out of benchmarks-other results\n"

.PHONY: benchmarks-tables
benchmarks-tables: PYTEST_OPTIONS = --compare-other-engines --benchmark-json=comparison.json
benchmarks-tables: benchmarks
$(PYTHON) benchmarks/tablize.py | tee docs/benchmarks-tables.rst
PYTHONPATH=. $(PYTHON) benchmarks/tablize.py | tee docs/benchmarks-tables.rst

include Makefile.virtualenv
include Makefile.release
25 changes: 13 additions & 12 deletions benchmarks/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,22 @@ def pytest_addoption(parser):
])

try:
import ujson
import hyperjson
except ImportError:
pass
else:
contenders.append(Contender('ujson',
ujson.dumps,
partial(ujson.loads, precise_float=True)))
string_contenders.extend([
Contender('ujson utf8',
partial(ujson.dumps, ensure_ascii=False),
ujson.loads),
Contender('ujson ascii',
partial(ujson.dumps, ensure_ascii=True),
ujson.loads),
])
contenders.append(Contender('hyperjson',
hyperjson.dumps,
hyperjson.loads))

try:
import orjson
except ImportError:
pass
else:
contenders.append(Contender('orjson',
orjson.dumps,
orjson.loads))


def pytest_generate_tests(metafunc):
Expand Down
45 changes: 25 additions & 20 deletions benchmarks/tablize.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,26 @@ def dumps_and_loads(benchmarks):
'rapidjson_c',
'rapidjson_nn_f',
'rapidjson_nn_c',
'ujson',
'hyperjson',
'orjson',
'simplejson',
'stdlib json',
'yajl')
s_headers = (r'``dumps()``\ [1]_',
r'``Encoder()``\ [2]_',
r'``dumps(n)``\ [3]_',
r'``Encoder(n)``\ [4]_',
r'ujson\ [5]_',
r'simplejson\ [6]_',
r'stdlib\ [7]_',
r'yajl\ [8]_')
d_headers = (r'``loads()``\ [9]_',
r'``Decoder()``\ [10]_',
r'``loads(n)``\ [11]_',
r'``Decoder(n)``\ [12]_',
r'ujson',
r'hyperjson\ [5]_',
r'orjson\ [6]_',
r'simplejson\ [7]_',
r'stdlib\ [8]_',
r'yajl\ [9]_')
d_headers = (r'``loads()``\ [10]_',
r'``Decoder()``\ [11]_',
r'``loads(n)``\ [12]_',
r'``Decoder(n)``\ [13]_',
r'hyperjson',
r'orjson',
r'simplejson',
r'stdlib',
r'yajl')
Expand All @@ -123,14 +126,15 @@ def dumps_and_loads(benchmarks):
'.. [2] ``rapidjson.Encoder()``',
'.. [3] ``rapidjson.dumps(number_mode=NM_NATIVE)``',
'.. [4] ``rapidjson.Encoder(number_mode=NM_NATIVE)``',
'.. [5] `ujson 1.35 <https://pypi.org/pypi/ujson/1.35>`__',
'.. [6] `simplejson 3.16.0 <https://pypi.org/pypi/simplejson/3.16.0>`__',
'.. [7] Python %d.%d.%d standard library ``json``' % sys.version_info[:3],
'.. [8] `yajl 0.3.5 <https://pypi.org/pypi/yajl/0.3.5>`__',
'.. [9] ``rapidjson.loads()``',
'.. [10] ``rapidjson.Decoder()``',
'.. [11] ``rapidjson.loads(number_mode=NM_NATIVE)``',
'.. [12] ``rapidjson.Decoder(number_mode=NM_NATIVE)``']
'.. [5] `hyperjson 0.2.4 <https://pypi.org/project/hyperjson/0.2.4/>`__',
'.. [6] `orjson 2.5.0 <https://pypi.org/project/orjson/2.5.0/>`__',
'.. [7] `simplejson 3.16.0 <https://pypi.org/pypi/simplejson/3.16.0>`__',
'.. [8] Python %d.%d.%d standard library ``json``' % sys.version_info[:3],
'.. [9] `yajl 0.3.5 <https://pypi.org/pypi/yajl/0.3.5>`__',
'.. [10] ``rapidjson.loads()``',
'.. [11] ``rapidjson.Decoder()``',
'.. [12] ``rapidjson.loads(number_mode=NM_NATIVE)``',
'.. [13] ``rapidjson.Decoder(number_mode=NM_NATIVE)``']

comparison = Comparison(contenders, benchmarks)

Expand All @@ -150,11 +154,12 @@ def dumps_and_loads(benchmarks):

def ascii_vs_utf8(benchmarks):
engines = (('rapidjson', 'rj'),
('ujson', 'uj'),
# ('hyperjson', 'hj'), # lacks ensure_ascii flag
# ('orjson', 'oj'), # lacks ensure_ascii flag
('simplejson', 'sj'),
('stdlib json', 'json'))
contenders = ['%s %s' % (e[0], k) for e in engines for k in ('ascii', 'utf8')]
i = 12
i = 13
s_headers = []
footnotes = []
for e in engines:
Expand Down
Loading