Files
pydantic-vs-msgspec/README.md
Eden Kirin 3b89f3a2d3 Readme
2023-10-11 21:29:27 +02:00

4.1 KiB

Pydantic vs MsgSpec

Libs used for benchmark:

Note that Pydantic used in benchmark is v2 which should be dozen of times faster than Pydantic v1. I have no time to waste benchmarking Pydantic v1.

Usage

Install virtual environment

poetry install

Create test data

  • Edit benchmark/factories.py and set COLUMNS_COUNT and PLANOGRAMS_COUNT to desired size.
  • Uncomment create_test_file(TEST_DATA_FILE) line in main.py
  • Run main.py

You can comment back this line after json test file is created.

Run benchmark

python main.py

Results

*** Running PydanticBenchmark
Finished in 10.781s
*** Running MsgSpecBenchmark
Finished in 1.725s
██████╗ ██╗   ██╗██████╗  █████╗ ███╗   ██╗████████╗██╗ ██████╗
██╔══██╗╚██╗ ██╔╝██╔══██╗██╔══██╗████╗  ██║╚══██╔══╝██║██╔════╝
██████╔╝ ╚████╔╝ ██║  ██║███████║██╔██╗ ██║   ██║   ██║██║
██╔═══╝   ╚██╔╝  ██║  ██║██╔══██║██║╚██╗██║   ██║   ██║██║
██║        ██║   ██████╔╝██║  ██║██║ ╚████║   ██║   ██║╚██████╗
╚═╝        ╚═╝   ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═══╝   ╚═╝   ╚═╝ ╚═════╝

██╗   ██╗ ██████╗ ██╗   ██╗    ███████╗██╗   ██╗ ██████╗██╗  ██╗    ██████╗  █████╗ ██╗     ██╗     ███████╗
╚██╗ ██╔╝██╔═══██╗██║   ██║    ██╔════╝██║   ██║██╔════╝██║ ██╔╝    ██╔══██╗██╔══██╗██║     ██║     ██╔════╝
 ╚████╔╝ ██║   ██║██║   ██║    ███████╗██║   ██║██║     █████╔╝     ██████╔╝███████║██║     ██║     ███████╗
  ╚██╔╝  ██║   ██║██║   ██║    ╚════██║██║   ██║██║     ██╔═██╗     ██╔══██╗██╔══██║██║     ██║     ╚════██║
   ██║   ╚██████╔╝╚██████╔╝    ███████║╚██████╔╝╚██████╗██║  ██╗    ██████╔╝██║  ██║███████╗███████╗███████║
   ╚═╝    ╚═════╝  ╚═════╝     ╚══════╝ ╚═════╝  ╚═════╝╚═╝  ╚═╝    ╚═════╝ ╚═╝  ╚═╝╚══════╝╚══════╝╚══════╝

██████╗ ██╗ ██████╗     ████████╗██╗███╗   ███╗███████╗
██╔══██╗██║██╔════╝     ╚══██╔══╝██║████╗ ████║██╔════╝
██████╔╝██║██║  ███╗       ██║   ██║██╔████╔██║█████╗
██╔══██╗██║██║   ██║       ██║   ██║██║╚██╔╝██║██╔══╝
██████╔╝██║╚██████╔╝       ██║   ██║██║ ╚═╝ ██║███████╗
╚═════╝ ╚═╝ ╚═════╝        ╚═╝   ╚═╝╚═╝     ╚═╝╚══════╝