|
1 |
| -## Node.js |
2 |
| - |
3 |
| -Running on Node.js `v20.9.0` |
4 |
| - |
5 |
| -=== Non-string fallback == |
6 |
| -JSON.parse x 9,464,387 ops/sec ±0.19% (97 runs sampled) |
7 |
| -destr x 255,562,708 ops/sec ±0.23% (98 runs sampled) |
8 |
| -safeDestr x 74,229,966 ops/sec ±0.42% (93 runs sampled) |
9 |
| -sjson: |
10 |
| -@hapi/bourne x 9,019,413 ops/sec ±0.32% (96 runs sampled) |
11 |
| -Fastest is destr |
12 |
| - |
13 |
| -=== Known values == |
14 |
| -JSON.parse x 23,600,894 ops/sec ±0.44% (92 runs sampled) |
15 |
| -destr x 78,297,469 ops/sec ±0.27% (98 runs sampled) |
16 |
| -safeDestr x 40,300,751 ops/sec ±0.46% (98 runs sampled) |
17 |
| -sjson x 16,228,475 ops/sec ±1.08% (94 runs sampled) |
18 |
| -@hapi/bourne x 20,756,877 ops/sec ±0.56% (97 runs sampled) |
19 |
| -Fastest is destr |
| 1 | +``` |
| 2 | +cpu: Apple M2 |
| 3 | +runtime: node v20.11.1 (arm64-darwin) |
20 | 4 |
|
21 |
| -=== plain string (short) == |
22 |
| -JSON.parse (try-catch) x 14,024,616 ops/sec ±0.37% (97 runs sampled) |
23 |
| -destr x 47,234,367 ops/sec ±2.82% (90 runs sampled) |
24 |
| -safeDestr x 32,067,177 ops/sec ±0.29% (97 runs sampled) |
25 |
| -sjson (try-catch) x 10,652,731 ops/sec ±0.33% (97 runs sampled) |
26 |
| -@hapi/bourne x 11,778,015 ops/sec ±1.12% (89 runs sampled) |
27 |
| -Fastest is destr |
| 5 | +benchmark time (avg) (min … max) |
| 6 | +-------------------------------------------------------------- |
| 7 | +• Non-string fallback |
| 8 | +-------------------------------------------------------------- |
| 9 | +destr 4.84 ns/iter (3.78 ns … 326 ns) |
| 10 | +JSON.parse 174 ns/iter (139 ns … 701 ns) |
| 11 | +safeDestr 31.18 ns/iter (18.41 ns … 337 ns) |
| 12 | +sjson error: text.charCodeAt is not a function |
| 13 | +TypeError: text.charCodeAt is not a function |
| 14 | +@hapi/bourne 157 ns/iter (144 ns … 314 ns) |
28 | 15 |
|
29 |
| -=== plain string (long) == |
30 |
| -JSON.parse (try-catch) x 156,139 ops/sec ±0.88% (93 runs sampled) |
31 |
| -destr x 38,673,125 ops/sec ±0.35% (94 runs sampled) |
32 |
| -safeDestr: |
33 |
| -sjson (try-catch) x 323,817 ops/sec ±0.80% (96 runs sampled) |
34 |
| -@hapi/bourne: |
35 |
| -Fastest is destr |
| 16 | +summary for Non-string fallback |
| 17 | + destr |
| 18 | + 6.44x faster than safeDestr |
| 19 | + 32.41x faster than @hapi/bourne |
| 20 | + 35.96x faster than JSON.parse |
36 | 21 |
|
37 |
| -=== package.json == |
38 |
| -JSON.parse x 357,325 ops/sec ±0.32% (98 runs sampled) |
39 |
| -destr x 295,762 ops/sec ±0.32% (98 runs sampled) |
40 |
| -safeDestr x 295,847 ops/sec ±0.13% (97 runs sampled) |
41 |
| -sjson x 297,089 ops/sec ±0.35% (97 runs sampled) |
42 |
| -@hapi/bourne x 323,762 ops/sec ±0.19% (97 runs sampled) |
43 |
| -Fastest is JSON.parse |
| 22 | +• Known values |
| 23 | +-------------------------------------------------------------- |
| 24 | +destr 22.56 ns/iter (15.85 ns … 136 ns) |
| 25 | +JSON.parse 95.87 ns/iter (89.92 ns … 227 ns) |
| 26 | +safeDestr 50.85 ns/iter (30.92 ns … 537 ns) |
| 27 | +sjson 113 ns/iter (109 ns … 266 ns) |
| 28 | +@hapi/bourne 105 ns/iter (98.02 ns … 112 ns) |
44 | 29 |
|
45 |
| -=== broken object == |
46 |
| -JSON.parse (try-catch) x 95,513 ops/sec ±0.50% (93 runs sampled) |
47 |
| -destr x 84,278 ops/sec ±0.37% (95 runs sampled) |
48 |
| -safeDestr: |
49 |
| -sjson (try-catch) x 163,887 ops/sec ±0.69% (95 runs sampled) |
50 |
| -@hapi/bourne: |
51 |
| -Fastest is sjson (try-catch) |
| 30 | +summary for Known values |
| 31 | + destr |
| 32 | + 2.25x faster than safeDestr |
| 33 | + 4.25x faster than JSON.parse |
| 34 | + 4.64x faster than @hapi/bourne |
| 35 | + 5.02x faster than sjson |
52 | 36 |
|
53 |
| -## Bun |
| 37 | +• plain string (short) |
| 38 | +-------------------------------------------------------------- |
| 39 | +destr 27.21 ns/iter (26.14 ns … 107 ns) |
| 40 | +JSON.parse (try-catch) 120 ns/iter (115 ns … 292 ns) |
| 41 | +safeDestr 62.07 ns/iter (41.56 ns … 720 ns) |
| 42 | +sjson (try-catch) 148 ns/iter (135 ns … 475 ns) |
| 43 | +@hapi/bourne 130 ns/iter (125 ns … 308 ns) |
54 | 44 |
|
55 |
| -Runnin on Bun `v1.0.7` |
| 45 | +summary for plain string (short) |
| 46 | + destr |
| 47 | + 2.28x faster than safeDestr |
| 48 | + 4.4x faster than JSON.parse (try-catch) |
| 49 | + 4.79x faster than @hapi/bourne |
| 50 | + 5.43x faster than sjson (try-catch) |
56 | 51 |
|
57 |
| -``` |
58 |
| -=== Non-string fallback == |
59 |
| -JSON.parse x 17,172,248 ops/sec ±2.51% (80 runs sampled) |
60 |
| -destr x 70,028,734 ops/sec ±10.62% (50 runs sampled) |
61 |
| -safeDestr x 26,543,362 ops/sec ±4.69% (70 runs sampled) |
62 |
| -sjson: |
63 |
| -@hapi/bourne x 14,412,494 ops/sec ±2.21% (82 runs sampled) |
64 |
| -Fastest is destr |
| 52 | +• plain string (long) |
| 53 | +-------------------------------------------------------------- |
| 54 | +destr 567 ns/iter (34.57 ns … 1'001 ns) |
| 55 | +JSON.parse (try-catch) 4'900 ns/iter (3'813 ns … 6'664 ns) |
| 56 | +safeDestr 4'751 ns/iter (4'284 ns … 5'953 ns) |
| 57 | +sjson (try-catch) 2'895 ns/iter (2'564 ns … 4'633 ns) |
| 58 | +@hapi/bourne 6'528 ns/iter (5'767 ns … 8'859 ns) |
65 | 59 |
|
66 |
| -=== Known values == |
67 |
| -JSON.parse x 37,889,947 ops/sec ±6.42% (63 runs sampled) |
68 |
| -destr x 31,602,584 ops/sec ±4.29% (72 runs sampled) |
69 |
| -safeDestr x 17,022,901 ops/sec ±3.09% (80 runs sampled) |
70 |
| -sjson x 16,439,558 ops/sec ±2.63% (82 runs sampled) |
71 |
| -@hapi/bourne x 25,914,930 ops/sec ±4.35% (69 runs sampled) |
72 |
| -Fastest is JSON.parse |
| 60 | +summary for plain string (long) |
| 61 | + destr |
| 62 | + 5.11x faster than sjson (try-catch) |
| 63 | + 8.38x faster than safeDestr |
| 64 | + 8.64x faster than JSON.parse (try-catch) |
| 65 | + 11.52x faster than @hapi/bourne |
73 | 66 |
|
74 |
| -=== plain string (short) == |
75 |
| -JSON.parse (try-catch) x 18,661,059 ops/sec ±2.92% (73 runs sampled) |
76 |
| -destr x 15,789,374 ops/sec ±2.66% (80 runs sampled) |
77 |
| -safeDestr x 10,512,090 ops/sec ±1.98% (83 runs sampled) |
78 |
| -sjson (try-catch) x 10,938,015 ops/sec ±1.68% (87 runs sampled) |
79 |
| -@hapi/bourne x 14,817,736 ops/sec ±2.66% (79 runs sampled) |
80 |
| -Fastest is JSON.parse (try-catch) |
| 67 | +• package.json |
| 68 | +-------------------------------------------------------------- |
| 69 | +destr 3'900 ns/iter (3'739 ns … 4'597 ns) |
| 70 | +JSON.parse 3'426 ns/iter (3'200 ns … 4'132 ns) |
| 71 | +safeDestr 4'290 ns/iter (3'795 ns … 6'540 ns) |
| 72 | +sjson 4'289 ns/iter (3'716 ns … 6'109 ns) |
| 73 | +@hapi/bourne 3'636 ns/iter (3'464 ns … 4'400 ns) |
81 | 74 |
|
82 |
| -=== plain string (long) == |
83 |
| -JSON.parse (try-catch) x 688,257 ops/sec ±0.39% (92 runs sampled) |
84 |
| -destr x 14,458,797 ops/sec ±2.54% (82 runs sampled) |
85 |
| -safeDestr: |
86 |
| -sjson (try-catch) x 531,925 ops/sec ±1.27% (94 runs sampled) |
87 |
| -@hapi/bourne: |
88 |
| -Fastest is destr |
| 75 | +summary for package.json |
| 76 | + destr |
| 77 | + 1.14x slower than JSON.parse |
| 78 | + 1.07x slower than @hapi/bourne |
| 79 | + 1.1x faster than sjson |
| 80 | + 1.1x faster than safeDestr |
89 | 81 |
|
90 |
| -=== package.json == |
91 |
| -JSON.parse x 405,237 ops/sec ±0.41% (96 runs sampled) |
92 |
| -destr x 58,580 ops/sec ±0.21% (97 runs sampled) |
93 |
| -safeDestr x 58,269 ops/sec ±0.21% (95 runs sampled) |
94 |
| -sjson x 316,115 ops/sec ±0.38% (94 runs sampled) |
95 |
| -@hapi/bourne x 351,669 ops/sec ±0.33% (98 runs sampled) |
96 |
| -Fastest is JSON.parse |
| 82 | +• broken object |
| 83 | +-------------------------------------------------------------- |
| 84 | +destr 3'978 ns/iter (3'766 ns … 4'634 ns) |
| 85 | +JSON.parse (try-catch) 3'478 ns/iter (3'199 ns … 4'281 ns) |
| 86 | +safeDestr 3'953 ns/iter (3'800 ns … 5'057 ns) |
| 87 | +sjson (try-catch) 3'930 ns/iter (3'724 ns … 4'593 ns) |
| 88 | +@hapi/bourne 3'655 ns/iter (3'455 ns … 4'265 ns) |
97 | 89 |
|
98 |
| -=== broken object == |
99 |
| -JSON.parse (try-catch) x 240,053 ops/sec ±0.56% (96 runs sampled) |
100 |
| -destr x 52,153 ops/sec ±0.40% (93 runs sampled) |
101 |
| -safeDestr: |
102 |
| -sjson (try-catch) x 210,145 ops/sec ±0.39% (96 runs sampled) |
103 |
| -@hapi/bourne: |
104 |
| -Fastest is JSON.parse (try-catch) |
| 90 | +summary for broken object |
| 91 | + destr |
| 92 | + 1.14x slower than JSON.parse (try-catch) |
| 93 | + 1.09x slower than @hapi/bourne |
| 94 | + 1.01x slower than sjson (try-catch) |
| 95 | + 1.01x slower than safeDestr |
105 | 96 | ```
|
0 commit comments