Skip to content

fuchsde/orjson-benchmark

Repository files navigation

Orjson-Benchmark

This repository is a copy of the benchmark to measure the performance and correctness of Python JSON libraries. It was copied and inspired from Orjson.

The goal is, using Poetry and Tox, to simplify the execution of the test and thus enable everyone to run the benchmark quickly.

Furthermore some improvements as naming the library version used and code refactoring were added.

To view the results visit the web app hosted on Heroku.

Reproducing the whole benchmark:

poetry run tox

Results can be found here:

Types

dataclass

Reproducing:

poetry run tox -e setup,update,dataclass

datetime

No benchmark available.

enum

No benchmark available.

float

No benchmark available.

int

No benchmark available.

numpy

Reproducing:

poetry run tox -e setup,update,numpy

str

No benchmark available.

nonstr

No benchmark available.

uuid

No benchmark available.

Correctness

No benchmark available.

Performance

Serialization and deserialization performance of orjson is better than ultrajson, rapidjson, simplejson, or json. The benchmarks are done on fixtures of real data:

  • twitter.json, 631.5KiB, results of a search on Twitter for "一", containing CJK strings, dictionaries of strings and arrays of dictionaries, indented.
  • github.json, 55.8KiB, a GitHub activity feed, containing dictionaries of strings and arrays of dictionaries, not indented.
  • citm_catalog.json, 1.7MiB, concert data, containing nested dictionaries of strings and arrays of integers, indented.
  • canada.json, 2.2MiB, coordinates of the Canadian border in GeoJSON format, containing floats and arrays, indented.

Latency

Reproducing:

poetry run tox -e setup,update,latency-dumps,latency-empty,latency-loads

Memory

Reproducing:

poetry run tox -e setup,update,memory

Other

Sorting

Reproducing:

poetry run tox -e setup,update,sort

Indent

Reproducing:

poetry run tox -e setup,update,indent