Skip to content

Commit

Permalink
chore: add bun to the bench results
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 24, 2023
1 parent f9c78d4 commit 523f3f1
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 28 deletions.
108 changes: 83 additions & 25 deletions BENCH.md
@@ -1,47 +1,105 @@
## Node.js

Running on Node.js `v20.9.0`

=== Non-string fallback ==
JSON.parse x 9,918,339 ops/sec 卤0.19% (100 runs sampled)
destr x 251,332,455 ops/sec 卤0.11% (96 runs sampled)
safeDestr x 69,678,071 ops/sec 卤0.26% (98 runs sampled)
JSON.parse x 9,464,387 ops/sec 卤0.19% (97 runs sampled)
destr x 255,562,708 ops/sec 卤0.23% (98 runs sampled)
safeDestr x 74,229,966 ops/sec 卤0.42% (93 runs sampled)
sjson:
@hapi/bourne x 9,421,906 ops/sec 卤0.19% (98 runs sampled)
@hapi/bourne x 9,019,413 ops/sec 卤0.32% (96 runs sampled)
Fastest is destr

=== Known values ==
JSON.parse x 25,309,285 ops/sec 卤0.17% (98 runs sampled)
destr x 64,017,380 ops/sec 卤0.25% (98 runs sampled)
safeDestr x 35,059,475 ops/sec 卤0.44% (97 runs sampled)
sjson x 13,417,836 ops/sec 卤0.24% (96 runs sampled)
@hapi/bourne x 22,905,370 ops/sec 卤0.75% (96 runs sampled)
JSON.parse x 23,600,894 ops/sec 卤0.44% (92 runs sampled)
destr x 78,297,469 ops/sec 卤0.27% (98 runs sampled)
safeDestr x 40,300,751 ops/sec 卤0.46% (98 runs sampled)
sjson x 16,228,475 ops/sec 卤1.08% (94 runs sampled)
@hapi/bourne x 20,756,877 ops/sec 卤0.56% (97 runs sampled)
Fastest is destr

=== plain string (short) ==
JSON.parse (try-catch) x 12,288,397 ops/sec 卤1.06% (90 runs sampled)
destr x 35,313,868 ops/sec 卤0.31% (93 runs sampled)
safeDestr x 23,935,624 ops/sec 卤0.36% (94 runs sampled)
sjson (try-catch) x 9,609,603 ops/sec 卤0.49% (98 runs sampled)
@hapi/bourne x 13,740,706 ops/sec 卤0.36% (93 runs sampled)
JSON.parse (try-catch) x 14,024,616 ops/sec 卤0.37% (97 runs sampled)
destr x 47,234,367 ops/sec 卤2.82% (90 runs sampled)
safeDestr x 32,067,177 ops/sec 卤0.29% (97 runs sampled)
sjson (try-catch) x 10,652,731 ops/sec 卤0.33% (97 runs sampled)
@hapi/bourne x 11,778,015 ops/sec 卤1.12% (89 runs sampled)
Fastest is destr

=== plain string (long) ==
JSON.parse (try-catch) x 153,418 ops/sec 卤0.51% (97 runs sampled)
destr x 35,035,853 ops/sec 卤1.48% (94 runs sampled)
JSON.parse (try-catch) x 156,139 ops/sec 卤0.88% (93 runs sampled)
destr x 38,673,125 ops/sec 卤0.35% (94 runs sampled)
safeDestr:
sjson (try-catch) x 328,793 ops/sec 卤0.93% (95 runs sampled)
sjson (try-catch) x 323,817 ops/sec 卤0.80% (96 runs sampled)
@hapi/bourne:
Fastest is destr

=== package.json ==
JSON.parse x 323,024 ops/sec 卤0.15% (98 runs sampled)
destr x 271,330 ops/sec 卤0.23% (98 runs sampled)
safeDestr x 270,665 ops/sec 卤0.16% (95 runs sampled)
sjson x 273,199 ops/sec 卤0.30% (96 runs sampled)
@hapi/bourne x 298,936 ops/sec 卤0.20% (98 runs sampled)
JSON.parse x 357,325 ops/sec 卤0.32% (98 runs sampled)
destr x 295,762 ops/sec 卤0.32% (98 runs sampled)
safeDestr x 295,847 ops/sec 卤0.13% (97 runs sampled)
sjson x 297,089 ops/sec 卤0.35% (97 runs sampled)
@hapi/bourne x 323,762 ops/sec 卤0.19% (97 runs sampled)
Fastest is JSON.parse

=== broken object ==
JSON.parse (try-catch) x 99,691 ops/sec 卤0.44% (93 runs sampled)
destr x 86,265 ops/sec 卤0.45% (97 runs sampled)
JSON.parse (try-catch) x 95,513 ops/sec 卤0.50% (93 runs sampled)
destr x 84,278 ops/sec 卤0.37% (95 runs sampled)
safeDestr:
sjson (try-catch) x 152,432 ops/sec 卤0.51% (96 runs sampled)
sjson (try-catch) x 163,887 ops/sec 卤0.69% (95 runs sampled)
@hapi/bourne:
Fastest is sjson (try-catch)

## Bun

Runnin on Bun `v1.0.7`

```
=== Non-string fallback ==
JSON.parse x 17,172,248 ops/sec 卤2.51% (80 runs sampled)
destr x 70,028,734 ops/sec 卤10.62% (50 runs sampled)
safeDestr x 26,543,362 ops/sec 卤4.69% (70 runs sampled)
sjson:
@hapi/bourne x 14,412,494 ops/sec 卤2.21% (82 runs sampled)
Fastest is destr
=== Known values ==
JSON.parse x 37,889,947 ops/sec 卤6.42% (63 runs sampled)
destr x 31,602,584 ops/sec 卤4.29% (72 runs sampled)
safeDestr x 17,022,901 ops/sec 卤3.09% (80 runs sampled)
sjson x 16,439,558 ops/sec 卤2.63% (82 runs sampled)
@hapi/bourne x 25,914,930 ops/sec 卤4.35% (69 runs sampled)
Fastest is JSON.parse
=== plain string (short) ==
JSON.parse (try-catch) x 18,661,059 ops/sec 卤2.92% (73 runs sampled)
destr x 15,789,374 ops/sec 卤2.66% (80 runs sampled)
safeDestr x 10,512,090 ops/sec 卤1.98% (83 runs sampled)
sjson (try-catch) x 10,938,015 ops/sec 卤1.68% (87 runs sampled)
@hapi/bourne x 14,817,736 ops/sec 卤2.66% (79 runs sampled)
Fastest is JSON.parse (try-catch)
=== plain string (long) ==
JSON.parse (try-catch) x 688,257 ops/sec 卤0.39% (92 runs sampled)
destr x 14,458,797 ops/sec 卤2.54% (82 runs sampled)
safeDestr:
sjson (try-catch) x 531,925 ops/sec 卤1.27% (94 runs sampled)
@hapi/bourne:
Fastest is destr
=== package.json ==
JSON.parse x 405,237 ops/sec 卤0.41% (96 runs sampled)
destr x 58,580 ops/sec 卤0.21% (97 runs sampled)
safeDestr x 58,269 ops/sec 卤0.21% (95 runs sampled)
sjson x 316,115 ops/sec 卤0.38% (94 runs sampled)
@hapi/bourne x 351,669 ops/sec 卤0.33% (98 runs sampled)
Fastest is JSON.parse
=== broken object ==
JSON.parse (try-catch) x 240,053 ops/sec 卤0.56% (96 runs sampled)
destr x 52,153 ops/sec 卤0.40% (93 runs sampled)
safeDestr:
sjson (try-catch) x 210,145 ops/sec 卤0.39% (96 runs sampled)
@hapi/bourne:
Fastest is JSON.parse (try-catch)
```
2 changes: 1 addition & 1 deletion bench.mjs
Expand Up @@ -2,7 +2,7 @@ import fs from "node:fs";
import Benchmark from "benchmark";
import sjson from "secure-json-parse";
import bourne from "@hapi/bourne";
import { destr, safeDestr } from "destr";
import { destr, safeDestr } from "./dist/index.mjs";

const { log } = console;

Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -20,7 +20,8 @@
"lib"
],
"scripts": {
"bench": "pnpm build && node ./bench.mjs",
"bench:bun": "pnpm build && bun --bun ./bench.mjs",
"bench:node": "pnpm build && node ./bench.mjs",
"build": "unbuild",
"dev": "vitest dev",
"lint": "eslint --ext .ts . && prettier -c src test",
Expand All @@ -42,4 +43,4 @@
"vitest": "^0.34.6"
},
"packageManager": "pnpm@8.9.2"
}
}

0 comments on commit 523f3f1

Please sign in to comment.