Benchmark results
The following benchmarks were conducted using Node v18.0.0 via the/bench directory in the source repository.
Node environment
Browser environment
Both competing libraries failed the reference patch set test, while Meros passed all correctness checks.
Performance characteristics
Bundle size
Meros is extremely lightweight:- Minified size: ~642 bytes
- Gzip size: Available in browser build
- Brotli size: Available in browser build
- Zero dependencies: No runtime dependencies
Memory efficiency
Meros uses streaming iterators to process multipart responses:- Incremental processing: Parts are yielded as they arrive
- No buffering of entire response: Only the current part is kept in memory
- Efficient boundary detection: Uses string/buffer searching instead of regex
Optimization options
Multiple parts per yield
For scenarios where you need to process multiple parts synchronously (e.g., GraphQL store updates), use themultiple option:
The
multiple option allows you to process all parts in a chunk synchronously, reducing the number of async iterations and improving throughput for batch operations.Running benchmarks
To run the benchmarks yourself:- Parsing speed across multiple parts
- JSON deserialization performance
- Boundary detection accuracy
- Correctness against reference implementations
Performance tips
Use the multiple option for batch processing
Use the multiple option for batch processing
When updating a GraphQL store or database, using
{ multiple: true } allows you to commit multiple parts in a single operation rather than one at a time.Avoid unnecessary async iteration
Avoid unnecessary async iteration
If you’re collecting all parts into an array anyway, consider using the
multiple option to reduce the number of yield points.Leverage the json flag
Leverage the json flag
Check the
json property on each part to avoid unnecessary type checking or parsing attempts:Use environment-specific imports
Use environment-specific imports
Import from
meros/browser or meros/node directly to avoid bundler overhead and ensure optimal code paths for your target environment.Related
- API Reference - Complete API documentation
- Troubleshooting - Common performance issues