diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-09-29 14:15:13 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-09-29 14:15:13 +0200 |
| commit | a8a89b3ed3101981d4d87ce50f924ea499c369fd (patch) | |
| tree | f3a3b51fa2eb6612652dfbc26bd9ee8527be2822 /README.md | |
| parent | ed979a49940b3054468b48ad1a9f97fab5a2fd81 (diff) | |
| download | ele-a8a89b3ed3101981d4d87ce50f924ea499c369fd.tar.gz ele-a8a89b3ed3101981d4d87ce50f924ea499c369fd.zip | |
Optimize release throughput and add reproducible CLI benchmarks
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -52,6 +52,25 @@ echo '{"user": {"settings": {"theme": "dark"}}}' | \ aip-filter "user.settings.theme = dark" ``` +## Performance + +Release builds optimize for speed rather than minimum executable size. The evaluator reuses compiled regexes and literals, borrows JSON collections, and searches overlapping phrases in linear time. JSON parsing still allocates memory for each record. + +To compare two release binaries, use Python 3: + +```bash +python3 bench/benchmark.py ./target/baseline ./target/release/aip-filter \ + --records 100000 --runs 5 +``` + +The benchmark generates JSON lines under `target/benchmarks`, checks that both binaries produce identical output, and reports median elapsed times for seven workloads. It alternates execution order and discards output during timing. Results depend on the machine and data. + +For a smaller binary, Cargo also supports a size-oriented build without changing the configuration: + +```bash +CARGO_PROFILE_RELEASE_OPT_LEVEL=z cargo build --release --locked +``` + ## API Implement `Filterable` for your type, compile the expression once with `Expr::compile`, and reuse `CompiledFilter::evaluate`. Compilation returns errors for unsupported expressions before any records are read. `serde_json::Value` implements `Filterable` directly and borrows arrays and objects without copying them. |
