fastify / fast-json-stringify

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

perf: removed jsonOutput variable because is useless #711

Closed cesco69 closed 5 months ago

cesco69 commented 5 months ago

Just removed a useless jsonOutput variable

Checking out "master"
Execute "npm run bench"

> fast-json-stringify@5.14.1 bench
> node ./benchmark/bench.js

short string............................................. x 23,463,000 ops/sec ±0.67% (190 runs sampled)
unsafe short string...................................... x 1,068,252,499 ops/sec ±0.38% (191 runs sampled)
short string with double quote........................... x 13,965,895 ops/sec ±0.46% (191 runs sampled)
long string without double quotes........................ x 15,826 ops/sec ±0.51% (191 runs sampled)
unsafe long string without double quotes................. x 1,063,725,876 ops/sec ±0.45% (188 runs sampled)
long string.............................................. x 16,194 ops/sec ±0.41% (192 runs sampled)
unsafe long string....................................... x 1,060,574,640 ops/sec ±0.41% (189 runs sampled)
number................................................... x 1,089,591,073 ops/sec ±0.47% (192 runs sampled)
integer.................................................. x 223,362,164 ops/sec ±0.51% (191 runs sampled)
formatted date-time...................................... x 1,689,801 ops/sec ±0.50% (189 runs sampled)
formatted date........................................... x 1,128,339 ops/sec ±0.49% (191 runs sampled)
formatted time........................................... x 1,132,623 ops/sec ±0.46% (191 runs sampled)
short array of numbers................................... x 77,715 ops/sec ±0.48% (192 runs sampled)
short array of integers.................................. x 64,242 ops/sec ±0.49% (191 runs sampled)
short array of short strings............................. x 20,174 ops/sec ±0.42% (190 runs sampled)
short array of long strings.............................. x 20,097 ops/sec ±0.52% (190 runs sampled)
short array of objects with properties of different types x 9,651 ops/sec ±0.43% (190 runs sampled)
object with number property.............................. x 1,065,574,419 ops/sec ±0.49% (187 runs sampled)
object with integer property............................. x 223,356,893 ops/sec ±0.44% (192 runs sampled)
object with short string property........................ x 22,830,848 ops/sec ±0.66% (191 runs sampled)
object with long string property......................... x 16,130 ops/sec ±0.40% (192 runs sampled)
object with properties of different types................ x 1,959,959 ops/sec ±1.01% (183 runs sampled)
simple object............................................ x 10,044,561 ops/sec ±0.50% (187 runs sampled)
simple object with required fields....................... x 9,947,067 ops/sec ±0.49% (190 runs sampled)
object with const string property........................ x 1,082,887,184 ops/sec ±0.50% (191 runs sampled)
object with const number property........................ x 1,067,647,246 ops/sec ±0.46% (190 runs sampled)
object with const bool property.......................... x 1,081,663,424 ops/sec ±0.48% (192 runs sampled)
object with const object property........................ x 1,057,316,158 ops/sec ±0.57% (189 runs sampled)
object with const null property.......................... x 1,032,466,116 ops/sec ±0.38% (191 runs sampled)

Checking out "perf-json-out"
Execute "npm run bench"

> fast-json-stringify@5.14.1 bench
> node ./benchmark/bench.js

short string............................................. x 23,225,101 ops/sec ±0.50% (191 runs sampled)
unsafe short string...................................... x 1,039,962,058 ops/sec ±0.36% (190 runs sampled)
short string with double quote........................... x 13,688,410 ops/sec ±0.51% (191 runs sampled)
long string without double quotes........................ x 15,626 ops/sec ±0.49% (189 runs sampled)
unsafe long string without double quotes................. x 1,054,726,016 ops/sec ±0.41% (189 runs sampled)
long string.............................................. x 16,203 ops/sec ±0.43% (191 runs sampled)
unsafe long string....................................... x 1,054,686,263 ops/sec ±0.39% (191 runs sampled)
number................................................... x 1,069,846,790 ops/sec ±0.49% (190 runs sampled)
integer.................................................. x 222,649,341 ops/sec ±0.47% (192 runs sampled)
formatted date-time...................................... x 1,672,035 ops/sec ±0.42% (192 runs sampled)
formatted date........................................... x 1,115,118 ops/sec ±0.42% (189 runs sampled)
formatted time........................................... x 1,117,664 ops/sec ±0.48% (189 runs sampled)
short array of numbers................................... x 76,177 ops/sec ±0.72% (190 runs sampled)
short array of integers.................................. x 66,153 ops/sec ±0.58% (191 runs sampled)
short array of short strings............................. x 20,496 ops/sec ±0.45% (191 runs sampled)
short array of long strings.............................. x 20,475 ops/sec ±0.48% (189 runs sampled)
short array of objects with properties of different types x 9,658 ops/sec ±0.37% (191 runs sampled)
object with number property.............................. x 1,065,146,831 ops/sec ±0.45% (190 runs sampled)
object with integer property............................. x 226,574,209 ops/sec ±0.46% (191 runs sampled)
object with short string property........................ x 23,308,135 ops/sec ±0.61% (190 runs sampled)
object with long string property......................... x 16,297 ops/sec ±0.48% (192 runs sampled)
object with properties of different types................ x 1,935,562 ops/sec ±1.02% (182 runs sampled)
simple object............................................ x 10,046,695 ops/sec ±0.42% (190 runs sampled)
simple object with required fields....................... x 9,988,890 ops/sec ±0.49% (191 runs sampled)
object with const string property........................ x 1,080,578,639 ops/sec ±0.49% (190 runs sampled)
object with const number property........................ x 1,082,359,961 ops/sec ±0.52% (191 runs sampled)
object with const bool property.......................... x 1,067,287,558 ops/sec ±0.42% (191 runs sampled)
object with const object property........................ x 1,072,875,010 ops/sec ±0.48% (188 runs sampled)
object with const null property.......................... x 1,057,273,573 ops/sec ±0.43% (190 runs sampled)

short string..............................................+1.02%
unsafe short string.......................................+2.72%
short string with double quote............................+2.03%
long string without double quotes.........................+1.28%
unsafe long string without double quotes..................+0.85%
long string...............................................-0.06%
unsafe long string........................................+0.56%
number....................................................+1.85%
integer...................................................+0.32%
formatted date-time.......................................+1.06%
formatted date............................................+1.19%
formatted time............................................+1.34%
short array of numbers....................................+2.02%
short array of integers...................................-2.89%
short array of short strings..............................-1.57%
short array of long strings...............................-1.85%
short array of objects with properties of different types.-0.07%
object with number property...............................+0.04%
object with integer property..............................-1.42%
object with short string property.........................-2.05%
object with long string property..........................-1.02%
object with properties of different types.................+1.26%
simple object.............................................-0.02%
simple object with required fields........................-0.42%
object with const string property.........................+0.21%
object with const number property.........................-1.36%
object with const bool property...........................+1.35%
object with const object property.........................-1.45%
object with const null property...........................-2.35%

Checklist