Skip to content

Commit ca1f5dd

Browse files
committed
docs: add yq and miller head-to-head benchmark stats
1 parent 44c6f77 commit ca1f5dd

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

README.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,27 +201,52 @@ Measured from `cargo bench --bench benchmarks` on macOS arm64 (Feb 2026).
201201

202202
### Head-to-Head (actual)
203203

204-
10,000-record JSON mapping task (`rename .name -> .username` + `where .age > 30`), same input file, same machine:
204+
All comparisons below were run on the same machine (macOS arm64), same 10,000-record dataset, with warmup and repeated timed runs via `hyperfine`.
205205

206-
| Tool | Mean runtime | Median runtime | Relative |
207-
|------|--------------|----------------|----------|
208-
| **morph** | **20.1 ms** | **20.0 ms** | **1.00x** |
209-
| jq | 46.1 ms | 46.3 ms | 2.29x slower |
206+
#### 1) JSON → YAML conversion
210207

211-
This test was run with warm cache and 12 timed iterations after warmup.
208+
| Tool | Mean runtime | Relative |
209+
|------|--------------|----------|
210+
| **morph** (`morph -f json -t yaml`) | **23.7 ms** | **1.00x** |
211+
| yq (`yq -P '.'`) | 713.2 ms | 30.03x slower |
212+
213+
#### 2) JSON transform (rename + filter)
214+
215+
Task: `rename .name -> .username` + `where .age > 30`
216+
217+
| Tool | Mean runtime | Relative |
218+
|------|--------------|----------|
219+
| **morph** | **18.3 ms** | **1.00x** |
220+
| jq | 40.0 ms | 2.19x slower |
221+
| yq | 101.5 ms | 5.55x slower |
222+
223+
#### 3) CSV → JSON conversion
224+
225+
| Tool | Mean runtime | Relative |
226+
|------|--------------|----------|
227+
| **morph** (`morph -f csv -t json`) | **11.7 ms** | **1.00x** |
228+
| miller (`mlr --icsv --ojson`) | 17.2 ms | 1.47x slower |
212229

213230
### Comparison commands
214231

215232
```bash
216-
# morph
217-
./target/release/morph -i /tmp/morph_bench.json -o /tmp/morph_out.json -m /tmp/morph_map.morph
218-
219-
# jq equivalent
220-
jq 'map(select(.age > 30) | .username=.name | del(.name))' /tmp/morph_bench.json > /tmp/jq_out.json
233+
# JSON -> YAML
234+
hyperfine --warmup 3 --runs 15 \
235+
"./target/release/morph -i bench.json -o /tmp/morph_out.yaml -f json -t yaml" \
236+
"yq -P '.' bench.json > /tmp/yq_out.yaml"
237+
238+
# JSON transform (rename + filter)
239+
hyperfine --warmup 3 --runs 20 \
240+
"./target/release/morph -i bench.json -o /tmp/morph_map.json -m mapping.morph -f json -t json" \
241+
"jq 'map(select(.age > 30) | .username=.name | del(.name))' bench.json > /tmp/jq_map.json" \
242+
"yq -o=json 'map(select(.age > 30) | .username = .name | del(.name))' bench.json > /tmp/yq_map.json"
243+
244+
# CSV -> JSON
245+
hyperfine --warmup 3 --runs 20 \
246+
"./target/release/morph -i bench.csv -o /tmp/morph_csv.json -f csv -t json" \
247+
"mlr --icsv --ojson cat bench.csv > /tmp/mlr_csv.json"
221248
```
222249

223-
More cross-tool comparisons (yq/mlr) will be added as those tools are available in CI on pinned hardware.
224-
225250
### Run Benchmarks Locally
226251

227252
```bash

0 commit comments

Comments
 (0)