json-fortran-benchmarks

January 7, 2026 ยท View on GitHub

Benchmarks for JSON Fortran parsers. Also comparison to Python.

To compile

fpm build --profile release

To run tests

# fun all the fortran tests:
fpm run --profile release

# run the python tests:
python json_test.py
python ujson_test.py
python rapidjson_test.py

Sample results:

The benchmarks were run on an M1 MacBook Pro.

To parse the canada.json file:

First, just the time to read the entire file into a character(len=:),allocatable string:

      read file to a string :   0.0003  seconds

Fortran libs

LibraryRuntime (sec)
json-fortran C0.0447
json-fortran0.0826
toml-f0.1079
jsonf0.2109
rojff0.2829
jonquil0.4208
fson0.9652

Note that json_fortran C is just json-fortran but using the string_to_real_mode=2 option, which uses the string to real functions from the C stdlib.

Python libs

LibraryRuntime (sec)
json0.038878583 seconds
rapidjson0.048005750 seconds
ujson0.016822333 seconds

See also

  • JSON [degenerateconic.com]