Performance Guide
jsonpathx ships with a performance-focused JS engine and a benchmark suite that compares against jsonpath-plus and jsonpath. The current suite shows jsonpathx leading most queries (44/48).
Benchmarks
Run the suite from bench/:
bash
cd bench
npm install
npm run benchThe suite covers small reference data, synthetic datasets, deep trees, wide objects, large arrays, and Unicode-heavy keys to expose different engine hot paths.
Performance Tips
- Prefer specific paths over recursive descent where possible.
- Use caching for repeated queries:
typescript
JSONPath.enableCache({ maxSize: 100, ttl: 60000 });- Avoid expensive filters if a path can narrow the search first.
- Keep resultType as
valuewhen you don't need paths/pointers.
Profiling
Use tools/profile.mjs for quick local profiling.