fastify / fast-json-stringify

2x faster than JSON.stringify()
MIT License
3.49k stars 207 forks source link

chore: benchmark fast-json-stringify vs JSON.stringify #692

Closed nigrosimone closed 6 months ago

nigrosimone commented 6 months ago

With this PR each benchmark is executed both with fast-json-stringify and JSON.stringify for help developer to compare the result

short string............................................. x 17,031,936 ops/sec ±1.16% (186 runs sampled) (fast-json-stringify)
short string............................................. x 9,878,418 ops/sec ±0.92% (189 runs sampled) (JSON.stringify)

unsafe short string...................................... x 754,072,385 ops/sec ±0.69% (188 runs sampled) (fast-json-stringify)
unsafe short string...................................... x 9,676,614 ops/sec ±1.53% (188 runs sampled) (JSON.stringify)

short string with double quote........................... x 9,396,306 ops/sec ±0.93% (187 runs sampled) (fast-json-stringify)
short string with double quote........................... x 9,309,407 ops/sec ±1.19% (187 runs sampled) (JSON.stringify)

long string without double quotes........................ x 28,134 ops/sec ±1.44% (184 runs sampled) (fast-json-stringify)
long string without double quotes........................ x 13,123 ops/sec ±1.27% (183 runs sampled) (JSON.stringify)

unsafe long string without double quotes................. x 707,753,414 ops/sec ±2.58% (186 runs sampled) (fast-json-stringify)
unsafe long string without double quotes................. x 11,775 ops/sec ±0.54% (186 runs sampled) (JSON.stringify)

long string.............................................. x 12,037 ops/sec ±0.48% (190 runs sampled) (fast-json-stringify)
long string.............................................. x 11,718 ops/sec ±0.98% (186 runs sampled) (JSON.stringify)

unsafe long string....................................... x 727,363,512 ops/sec ±0.84% (189 runs sampled) (fast-json-stringify)
unsafe long string....................................... x 12,137 ops/sec ±0.44% (190 runs sampled) (JSON.stringify)

number................................................... x 761,039,377 ops/sec ±0.32% (192 runs sampled) (fast-json-stringify)
number................................................... x 16,054,549 ops/sec ±1.14% (183 runs sampled) (JSON.stringify)

integer.................................................. x 186,907,293 ops/sec ±0.74% (191 runs sampled) (fast-json-stringify)
integer.................................................. x 16,886,344 ops/sec ±1.86% (182 runs sampled) (JSON.stringify)

formatted date-time...................................... x 1,167,297 ops/sec ±1.03% (187 runs sampled) (fast-json-stringify)
formatted date-time...................................... x 550,689 ops/sec ±1.16% (185 runs sampled) (JSON.stringify)

formatted date........................................... x 782,367 ops/sec ±1.14% (185 runs sampled) (fast-json-stringify)
formatted date........................................... x 491,574 ops/sec ±5.02% (182 runs sampled) (JSON.stringify)

formatted time........................................... x 790,945 ops/sec ±0.96% (184 runs sampled) (fast-json-stringify)
formatted time........................................... x 533,953 ops/sec ±1.15% (185 runs sampled) (JSON.stringify)

short array of numbers................................... x 56,663 ops/sec ±4.98% (156 runs sampled) (fast-json-stringify)
short array of numbers................................... x 14,718 ops/sec ±3.91% (153 runs sampled) (JSON.stringify)

short array of integers.................................. x 42,258 ops/sec ±4.17% (153 runs sampled) (fast-json-stringify)
short array of integers.................................. x 12,509 ops/sec ±4.34% (148 runs sampled) (JSON.stringify)

Checklist