mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
58c92d6d82
* Adding compile time json path * using string_view * Adding support for compile-time json pointer as well. * Removing unnecessary comment * Tests now working, still will re-review. * Adding documentation on the compile-time json path/pointer parsing feature. * Adding benchmark showing the significant performance advantage of using compiled paths whenever you have them a priori. * going for JSONPath (correct wording). * minor update (mostly doc) --------- Co-authored-by: Daniel Lemire <daniel@lemire.me>
Accessor Performance Benchmarks (C++26)
These benchmarks compare the performance of runtime vs compile-time JSON accessors.
For the comparison to be meaningful, you must build simdjson with support for
C++26 reflexion. See the p2996 repository in the main project directory.
Files
accessor_benchmark.h- Common benchmark framework and test dataruntime_accessors.h- Runtimeat_path()benchmarkscompile_time_accessors.h- Compile-timeat_path_compiled()benchmarks (requires C++26 reflection)
Benchmarks
Each benchmark measures parsing + single field access:
- accessor_simple - Simple field:
.name - accessor_nested - Nested field:
.address.city - accessor_deep - Deep nested field:
.address.coordinates.lat
Building (Linux/macOS)
cmake -B build -D SIMDJSON_STATIC_REFLECTION=ON -DSIMDJSON_DEVELOPER_MODE=ON
cmake --build build --target=bench_ondemand
The SIMDJSON_STATIC_REFLECTION will be made unnecessary once mainstream compilers
begin supporting C++26 sufficiently well.
Running (Linux/macOS)
# Run all accessor benchmarks
./build/bench_ondemand --benchmark_filter="accessor"
Results
We find that compile-time accessors show performance improvements that scale with path depth:
- Simple fields: ~1.2x faster
- Nested fields: ~1.5x faster
- Deep nested fields: ~1.8x faster
The speedup comes from eliminating runtime path parsing and conversion overhead.