Skip to content

Nambers/ssrJSON-benchmark

Repository files navigation

ssrJSON-benchmark

PyPI - Version PyPI - Wheel

The ssrJSON benchmark repository.

Benchmark Results

The benchmark results can be found in website results or GitHub results. Contributing your benchmark result is welcomed.

Quick jump for

Usage

pip install ssrjson-benchmark[all]  # Install all dependencies for benchmarking and printing PDF / Markdown
# pip install ssrjson-benchmark[benchmark]  # Only install third-party JSON libraries for benchmarking
# pip install ssrjson-benchmark[visual]  # Only install dependencies for generating PDF / Markdown report
# pip install ssrjson-benchmark  # Clean install without any dependency
python -m ssrjson_benchmark full -h # Run benchmark + generate PDF report in one command
# python -m ssrjson_benchmark benchmark -h  # Run benchmark and generate JSON benchmark result
# python -m ssrjson_benchmark print -h # Generate report from previously saved JSON benchmark result

Notes

  • This repository conducts benchmarking using json, ujson,pydantic, msgspec, orjson, and ssrJSON. The benchmark for dumps_to_str aims to produce a str object. If a JSON library's dumps-related interface only outputs a bytes object, it will be substituted with dumps followed by a single decode("utf-8") operation. Similarly, for the dumps_to_bytes test, if the JSON library's dumps-related interface only outputs a str object, it will be replaced with dumps followed by a single encode("utf-8") operation.
  • To ensure the accuracy of benchmark results, this repository differentiates between scenarios with and without UTF-8 caches when testing dumps_to_bytes. For dumps_to_str and loads, since these methods are unrelated to encoding str objects to UTF-8, the data sources do not involve any UTF-8 cache, and no distinction is made in their tests.
    • Cache writing of ssrJSON is disabled globally when running benchmark.
    • We use orjson.dumps to create UTF-8 cache for all benchmark targets.
    • Test with UTF-8 cache is skipped when the whole JSON object is ASCII.
  • The performance of JSON encoding is primarily constrained by the speed of writing to the buffer, whereas decoding performance is mainly limited by the frequent invocation of CPython interfaces for object creation. During decoding, both ssrJSON and orjson employ short key caching to reduce the number of object creations, and this caching mechanism is global in both libraries. As a result, decoding benchmark tests may not accurately reflect the conditions encountered in real-world production environments.
  • The files simple_object.json and simple_object_zh.json do not represent real-world data; they are used to compare the performance of the fast path. Therefore, the benchmark results from these test cases should not be interpreted as indicative of actual performance in production environment.

About

benchmark of ssrJSON

Resources

License

Stars

Watchers

Forks

Contributors