Run this code using Deno:
deno run https://gist.githubusercontent.com/crabmusket/2c8c6e692974edd56cd6ab8fee14addd/raw/869958a7094daf17b36be6ac078aa0eafb4b0a9d/benchmark.js
It will prompt you for two network permissions, to download the sample data files.
An example of results from my laptop:
JSON with lots of strings:
┌───────┬──────────────────┬──────────────────────────────────────────┐
│ (idx) │ method │ result │
├───────┼──────────────────┼──────────────────────────────────────────┤
│ 0 │ "JSON.stringify" │ "53,458 ops/sec ±5.42% (150004 samples)" │
│ 1 │ "msgpack.encode" │ "17,388 ops/sec ±5.25% (50252 samples)" │
└───────┴──────────────────┴──────────────────────────────────────────┘
GeoJSON with lots of numbers:
┌───────┬──────────────────┬───────────────────────────────────────┐
│ (idx) │ method │ result │
├───────┼──────────────────┼───────────────────────────────────────┤
│ 0 │ "JSON.stringify" │ "460 ops/sec ±1.84% (1389 samples)" │
│ 1 │ "msgpack.encode" │ "1,554 ops/sec ±4.26% (4640 samples)" │
└───────┴──────────────────┴───────────────────────────────────────┘
GeoJSON with flattened arrays:
┌───────┬──────────────────┬──────────────────────────────────────┐
│ (idx) │ method │ result │
├───────┼──────────────────┼──────────────────────────────────────┤
│ 0 │ "JSON.stringify" │ "429 ops/sec ±1.82% (1295 samples)" │
│ 1 │ "msgpack.encode" │ "2,762 ops/sec ±4.7% (8219 samples)" │
└───────┴──────────────────┴──────────────────────────────────────┘
GeoJSON with Float64Arrays:
┌───────┬──────────────────┬─────────────────────────────────────────┐
│ (idx) │ method │ result │
├───────┼──────────────────┼─────────────────────────────────────────┤
│ 0 │ "JSON.stringify" │ "359 ops/sec ±2.16% (1081 samples)" │
│ 1 │ "msgpack.encode" │ "13,441 ops/sec ±5.15% (39463 samples)" │
└───────┴──────────────────┴─────────────────────────────────────────┘
This just goes to show that your data, and its layout, can have significant effects on benchmarks.