add optimizer
Checklist
- [ ] run
npm run testandnpm run benchmark - [ ] tests and/or benchmarks are included
- [ ] documentation is changed or added
- [ ] commit message and code follows the Developer's Certification of Origin and the Code of conduct
how much perf would this get us?
I am still investigating
Odd:
before:
short string............................................. x 43,029,750 ops/sec ±0.82% (191 runs sampled)
short string with double quote........................... x 13,328,954 ops/sec ±0.33% (189 runs sampled)
long string without double quotes........................ x 26,316 ops/sec ±0.27% (192 runs sampled)
long string.............................................. x 11,696 ops/sec ±0.17% (192 runs sampled)
number................................................... x 1,354,808,191 ops/sec ±0.11% (190 runs sampled)
integer.................................................. x 222,011,571 ops/sec ±0.08% (193 runs sampled)
formatted date-time...................................... x 2,838,326 ops/sec ±0.22% (192 runs sampled)
formatted date........................................... x 1,595,951 ops/sec ±0.23% (191 runs sampled)
formatted time........................................... x 1,603,617 ops/sec ±0.22% (190 runs sampled)
short array of numbers................................... x 75,758 ops/sec ±0.36% (189 runs sampled)
short array of integers.................................. x 68,997 ops/sec ±0.46% (190 runs sampled)
short array of short strings............................. x 22,570 ops/sec ±0.28% (189 runs sampled)
short array of long strings.............................. x 22,504 ops/sec ±0.25% (188 runs sampled)
short array of objects with properties of different types x 11,132 ops/sec ±0.33% (189 runs sampled)
object with number property.............................. x 1,341,001,463 ops/sec ±0.13% (188 runs sampled)
object with integer property............................. x 221,718,067 ops/sec ±0.11% (193 runs sampled)
object with short string property........................ x 41,396,300 ops/sec ±0.69% (189 runs sampled)
object with long string property......................... x 11,630 ops/sec ±0.19% (192 runs sampled)
object with properties of different types................ x 2,129,851 ops/sec ±0.55% (187 runs sampled)
simple object............................................ x 9,928,667 ops/sec ±0.44% (190 runs sampled)
object with const string property........................ x 1,354,504,033 ops/sec ±0.06% (194 runs sampled)
object with const number property........................ x 1,356,175,724 ops/sec ±0.07% (194 runs sampled)
object with const bool property.......................... x 1,349,457,006 ops/sec ±0.13% (191 runs sampled)
object with const object property........................ x 1,352,233,428 ops/sec ±0.14% (193 runs sampled)
object with const null property.......................... x 1,356,402,514 ops/sec ±0.08% (193 runs sampled)
after
short string............................................. x 42,957,374 ops/sec ±0.53% (191 runs sampled)
short string with double quote........................... x 13,084,788 ops/sec ±0.74% (186 runs sampled)
long string without double quotes........................ x 26,446 ops/sec ±0.32% (191 runs sampled)
long string.............................................. x 11,737 ops/sec ±0.17% (192 runs sampled)
number................................................... x 1,361,444,317 ops/sec ±0.07% (192 runs sampled)
integer.................................................. x 222,455,101 ops/sec ±0.08% (194 runs sampled)
formatted date-time...................................... x 2,961,085 ops/sec ±0.18% (189 runs sampled)
formatted date........................................... x 1,642,124 ops/sec ±0.47% (191 runs sampled)
formatted time........................................... x 1,637,101 ops/sec ±0.20% (190 runs sampled)
short array of numbers................................... x 75,280 ops/sec ±0.35% (187 runs sampled)
short array of integers.................................. x 69,451 ops/sec ±0.43% (190 runs sampled)
short array of short strings............................. x 22,055 ops/sec ±0.30% (190 runs sampled)
short array of long strings.............................. x 23,073 ops/sec ±0.43% (191 runs sampled)
short array of objects with properties of different types x 10,003 ops/sec ±0.28% (190 runs sampled)
object with number property.............................. x 1,345,255,460 ops/sec ±0.13% (187 runs sampled)
object with integer property............................. x 224,592,369 ops/sec ±0.06% (193 runs sampled)
object with short string property........................ x 42,360,931 ops/sec ±0.23% (191 runs sampled)
object with long string property......................... x 11,612 ops/sec ±0.19% (192 runs sampled)
object with properties of different types................ x 1,768,995 ops/sec ±0.47% (188 runs sampled)
simple object............................................ x 12,824,498 ops/sec ±0.52% (190 runs sampled)
object with const string property........................ x 1,361,069,070 ops/sec ±0.08% (194 runs sampled)
object with const number property........................ x 1,360,204,001 ops/sec ±0.11% (189 runs sampled)
object with const bool property.......................... x 1,354,428,630 ops/sec ±0.06% (194 runs sampled)
simple object is faster and I kind of can break the perf of typia. but "object with properties of different types" is slower.
Node: 14 PR:
FJS creation x 3,711 ops/sec ±1.90% (89 runs sampled)
CJS creation x 123,120 ops/sec ±0.53% (91 runs sampled)
AJV Serialize creation x 21,962,208 ops/sec ±0.30% (95 runs sampled)
JSON.stringify array x 3,412 ops/sec ±0.40% (97 runs sampled)
fast-json-stringify array default x 4,400 ops/sec ±0.37% (97 runs sampled)
fast-json-stringify array json-stringify x 4,347 ops/sec ±0.24% (96 runs sampled)
compile-json-stringify array x 4,567 ops/sec ±0.59% (95 runs sampled)
AJV Serialize array x 4,696 ops/sec ±0.28% (94 runs sampled)
JSON.stringify large array x 168 ops/sec ±0.23% (85 runs sampled)
fast-json-stringify large array default x 68.67 ops/sec ±0.22% (71 runs sampled)
fast-json-stringify large array json-stringify x 169 ops/sec ±0.33% (85 runs sampled)
compile-json-stringify large array x 211 ops/sec ±0.26% (82 runs sampled)
AJV Serialize large array x 77.75 ops/sec ±0.15% (79 runs sampled)
JSON.stringify long string x 11,063 ops/sec ±0.31% (97 runs sampled)
fast-json-stringify long string x 11,063 ops/sec ±0.14% (97 runs sampled)
compile-json-stringify long string x 11,040 ops/sec ±0.24% (95 runs sampled)
AJV Serialize long string x 14,319 ops/sec ±0.55% (95 runs sampled)
JSON.stringify short string x 8,482,727 ops/sec ±0.17% (96 runs sampled)
fast-json-stringify short string x 20,869,840 ops/sec ±0.10% (95 runs sampled)
compile-json-stringify short string x 22,576,109 ops/sec ±0.21% (92 runs sampled)
AJV Serialize short string x 21,958,591 ops/sec ±0.23% (93 runs sampled)
JSON.stringify obj x 2,035,658 ops/sec ±0.15% (98 runs sampled)
fast-json-stringify obj x 4,650,393 ops/sec ±0.64% (94 runs sampled)
compile-json-stringify obj x 11,017,459 ops/sec ±0.17% (94 runs sampled)
AJV Serialize obj x 6,323,638 ops/sec ±0.77% (97 runs sampled)
JSON stringify date x 698,911 ops/sec ±0.25% (93 runs sampled)
fast-json-stringify date format x 1,486,577 ops/sec ±0.17% (96 runs sampled)
compile-json-stringify date format x 695,021 ops/sec ±0.44% (97 runs sampled)
MAIN:
Node: 16 PR:
FJS creation x 2,634 ops/sec ±4.09% (82 runs sampled)
CJS creation x 102,956 ops/sec ±1.10% (85 runs sampled)
AJV Serialize creation x 35,385,341 ops/sec ±0.91% (85 runs sampled)
JSON.stringify array x 3,091 ops/sec ±0.95% (88 runs sampled)
fast-json-stringify array default x 4,514 ops/sec ±1.42% (89 runs sampled)
fast-json-stringify array json-stringify x 4,524 ops/sec ±1.70% (88 runs sampled)
compile-json-stringify array x 4,570 ops/sec ±1.66% (85 runs sampled)
AJV Serialize array x 4,863 ops/sec ±1.78% (85 runs sampled)
JSON.stringify large array x 152 ops/sec ±1.22% (78 runs sampled)
fast-json-stringify large array default x 65.93 ops/sec ±1.06% (67 runs sampled)
fast-json-stringify large array json-stringify x 146 ops/sec ±1.33% (73 runs sampled)
compile-json-stringify large array x 204 ops/sec ±1.43% (80 runs sampled)
AJV Serialize large array x 65.88 ops/sec ±1.38% (67 runs sampled)
JSON.stringify long string x 8,578 ops/sec ±1.07% (89 runs sampled)
fast-json-stringify long string x 8,405 ops/sec ±1.11% (86 runs sampled)
compile-json-stringify long string x 8,693 ops/sec ±0.93% (89 runs sampled)
AJV Serialize long string x 14,493 ops/sec ±0.75% (91 runs sampled)
JSON.stringify short string x 7,092,199 ops/sec ±0.73% (88 runs sampled)
fast-json-stringify short string x 19,361,119 ops/sec ±0.94% (89 runs sampled)
compile-json-stringify short string x 23,479,937 ops/sec ±0.75% (86 runs sampled)
AJV Serialize short string x 21,430,168 ops/sec ±0.78% (88 runs sampled)
JSON.stringify obj x 1,784,948 ops/sec ±0.75% (89 runs sampled)
fast-json-stringify obj x 4,798,556 ops/sec ±1.20% (87 runs sampled)
compile-json-stringify obj x 11,216,626 ops/sec ±0.82% (88 runs sampled)
AJV Serialize obj x 6,352,605 ops/sec ±1.08% (89 runs sampled)
JSON stringify date x 648,662 ops/sec ±0.73% (90 runs sampled)
fast-json-stringify date format x 1,368,345 ops/sec ±0.93% (87 runs sampled)
compile-json-stringify date format x 623,387 ops/sec ±1.03% (88 runs sampled)
MAIN:
Node: 18 PR:
FJS creation x 2,728 ops/sec ±1.37% (84 runs sampled)
CJS creation x 108,147 ops/sec ±0.38% (91 runs sampled)
AJV Serialize creation x 28,435,693 ops/sec ±0.24% (93 runs sampled)
JSON.stringify array x 2,824 ops/sec ±0.15% (97 runs sampled)
fast-json-stringify array default x 3,594 ops/sec ±0.15% (95 runs sampled)
fast-json-stringify array json-stringify x 3,583 ops/sec ±0.98% (96 runs sampled)
compile-json-stringify array x 3,969 ops/sec ±0.16% (95 runs sampled)
AJV Serialize array x 4,110 ops/sec ±0.17% (94 runs sampled)
JSON.stringify large array x 137 ops/sec ±0.21% (86 runs sampled)
fast-json-stringify large array default x 55.94 ops/sec ±0.85% (71 runs sampled)
fast-json-stringify large array json-stringify x 135 ops/sec ±0.27% (85 runs sampled)
compile-json-stringify large array x 179 ops/sec ±0.21% (82 runs sampled)
AJV Serialize large array x 64.35 ops/sec ±0.35% (65 runs sampled)
JSON.stringify long string x 9,323 ops/sec ±0.67% (96 runs sampled)
fast-json-stringify long string x 9,349 ops/sec ±0.11% (97 runs sampled)
compile-json-stringify long string x 9,354 ops/sec ±0.12% (97 runs sampled)
AJV Serialize long string x 12,472 ops/sec ±0.65% (96 runs sampled)
JSON.stringify short string x 7,178,537 ops/sec ±0.08% (96 runs sampled)
fast-json-stringify short string x 15,835,418 ops/sec ±0.15% (94 runs sampled)
compile-json-stringify short string x 17,358,744 ops/sec ±0.51% (91 runs sampled)
AJV Serialize short string x 17,413,292 ops/sec ±0.24% (94 runs sampled)
JSON.stringify obj x 1,750,009 ops/sec ±0.07% (94 runs sampled)
fast-json-stringify obj x 3,980,103 ops/sec ±0.73% (94 runs sampled)
compile-json-stringify obj x 8,631,351 ops/sec ±0.20% (93 runs sampled)
AJV Serialize obj x 5,047,617 ops/sec ±0.96% (92 runs sampled)
JSON stringify date x 644,810 ops/sec ±0.15% (94 runs sampled)
fast-json-stringify date format x 1,287,131 ops/sec ±0.14% (96 runs sampled)
compile-json-stringify date format x 643,402 ops/sec ±0.56% (97 runs sampled)
MAIN:
---
**Node**: 20
**PR**:
FJS creation x 2,957 ops/sec ±1.61% (84 runs sampled) CJS creation x 114,186 ops/sec ±0.36% (97 runs sampled) AJV Serialize creation x 35,162,529 ops/sec ±0.36% (90 runs sampled) JSON.stringify array x 2,769 ops/sec ±0.23% (97 runs sampled) fast-json-stringify array default x 3,833 ops/sec ±0.24% (95 runs sampled) fast-json-stringify array json-stringify x 3,792 ops/sec ±0.32% (95 runs sampled) compile-json-stringify array x 4,299 ops/sec ±0.75% (96 runs sampled) AJV Serialize array x 4,422 ops/sec ±0.15% (94 runs sampled) JSON.stringify large array x 139 ops/sec ±0.13% (79 runs sampled) fast-json-stringify large array default x 64.07 ops/sec ±0.47% (66 runs sampled) fast-json-stringify large array json-stringify x 139 ops/sec ±0.51% (78 runs sampled) compile-json-stringify large array x 202 ops/sec ±0.13% (86 runs sampled) AJV Serialize large array x 72.12 ops/sec ±0.23% (74 runs sampled) JSON.stringify long string x 9,153 ops/sec ±0.55% (95 runs sampled) fast-json-stringify long string x 9,153 ops/sec ±0.11% (94 runs sampled) compile-json-stringify long string x 9,170 ops/sec ±0.12% (94 runs sampled) AJV Serialize long string x 12,752 ops/sec ±0.59% (95 runs sampled) JSON.stringify short string x 6,807,008 ops/sec ±0.14% (97 runs sampled) fast-json-stringify short string x 15,606,902 ops/sec ±0.15% (91 runs sampled) compile-json-stringify short string x 19,759,933 ops/sec ±0.51% (95 runs sampled) AJV Serialize short string x 19,262,476 ops/sec ±1.25% (96 runs sampled) JSON.stringify obj x 1,820,925 ops/sec ±0.11% (97 runs sampled) fast-json-stringify obj x 4,309,152 ops/sec ±0.62% (92 runs sampled) compile-json-stringify obj x 10,652,129 ops/sec ±0.40% (96 runs sampled) AJV Serialize obj x 6,234,365 ops/sec ±0.53% (95 runs sampled) JSON stringify date x 525,689 ops/sec ±0.23% (94 runs sampled) fast-json-stringify date format x 831,822 ops/sec ±0.13% (96 runs sampled) compile-json-stringify date format x 518,188 ops/sec ±0.44% (92 runs sampled)
**MAIN**:
PR:
short string............................................. x 11,803,909 ops/sec ±0.38% (193 runs sampled)
short string with double quote........................... x 7,693,971 ops/sec ±0.15% (194 runs sampled)
long string without double quotes........................ x 12,623 ops/sec ±0.30% (194 runs sampled)
long string.............................................. x 11,167 ops/sec ±0.18% (194 runs sampled)
number................................................... x 708,759,625 ops/sec ±0.09% (194 runs sampled)
integer.................................................. x 147,420,378 ops/sec ±0.12% (194 runs sampled)
formatted date-time...................................... x 2,104,912 ops/sec ±0.15% (194 runs sampled)
formatted date........................................... x 1,527,222 ops/sec ±0.15% (194 runs sampled)
formatted time........................................... x 1,530,488 ops/sec ±0.21% (194 runs sampled)
short array of numbers................................... x 50,510 ops/sec ±0.30% (193 runs sampled)
short array of integers.................................. x 43,760 ops/sec ±0.33% (194 runs sampled)
short array of short strings............................. x 11,712 ops/sec ±0.26% (193 runs sampled)
short array of long strings.............................. x 11,717 ops/sec ±0.23% (193 runs sampled)
short array of objects with properties of different types x 5,721 ops/sec ±0.27% (194 runs sampled)
object with number property.............................. x 702,446,223 ops/sec ±0.09% (194 runs sampled)
object with integer property............................. x 146,067,259 ops/sec ±0.10% (194 runs sampled)
object with short string property........................ x 11,609,885 ops/sec ±0.21% (193 runs sampled)
object with long string property......................... x 11,111 ops/sec ±0.19% (194 runs sampled)
object with properties of different types................ x 1,071,796 ops/sec ±0.39% (192 runs sampled)
simple object............................................ x 5,261,622 ops/sec ±0.19% (192 runs sampled)
simple object with required fields....................... x 5,323,505 ops/sec ±0.17% (189 runs sampled)
object with const string property........................ x 708,716,498 ops/sec ±0.10% (194 runs sampled)
object with const number property........................ x 708,124,459 ops/sec ±0.10% (194 runs sampled)
object with const bool property.......................... x 708,906,284 ops/sec ±0.10% (194 runs sampled)
object with const object property........................ x 708,516,305 ops/sec ±0.13% (193 runs sampled)
object with const null property.......................... x 709,119,322 ops/sec ±0.08% (194 runs sampled)
MASTER:
short string............................................. x 13,116,407 ops/sec ±0.36% (192 runs sampled)
short string with double quote........................... x 8,215,053 ops/sec ±1.53% (191 runs sampled)
long string without double quotes........................ x 12,642 ops/sec ±0.39% (193 runs sampled)
long string.............................................. x 11,095 ops/sec ±0.22% (194 runs sampled)
number................................................... x 707,322,962 ops/sec ±0.08% (194 runs sampled)
integer.................................................. x 147,242,881 ops/sec ±0.09% (194 runs sampled)
formatted date-time...................................... x 2,097,135 ops/sec ±0.11% (194 runs sampled)
formatted date........................................... x 1,522,072 ops/sec ±0.18% (194 runs sampled)
formatted time........................................... x 1,523,511 ops/sec ±0.17% (193 runs sampled)
short array of numbers................................... x 50,210 ops/sec ±0.32% (194 runs sampled)
short array of integers.................................. x 42,927 ops/sec ±0.28% (194 runs sampled)
short array of short strings............................. x 12,355 ops/sec ±0.22% (194 runs sampled)
short array of long strings.............................. x 12,290 ops/sec ±0.25% (193 runs sampled)
short array of objects with properties of different types x 6,084 ops/sec ±0.28% (192 runs sampled)
object with number property.............................. x 702,640,549 ops/sec ±0.10% (194 runs sampled)
object with integer property............................. x 148,226,732 ops/sec ±0.07% (194 runs sampled)
object with short string property........................ x 12,823,323 ops/sec ±0.39% (193 runs sampled)
object with long string property......................... x 11,119 ops/sec ±0.18% (193 runs sampled)
object with properties of different types................ x 1,191,205 ops/sec ±0.30% (191 runs sampled)
simple object............................................ x 5,983,056 ops/sec ±0.19% (194 runs sampled)
simple object with required fields....................... x 5,883,492 ops/sec ±0.16% (194 runs sampled)
object with const string property........................ x 709,006,986 ops/sec ±0.09% (194 runs sampled)
object with const number property........................ x 709,278,837 ops/sec ±0.10% (194 runs sampled)
object with const bool property.......................... x 708,819,907 ops/sec ±0.11% (193 runs sampled)
object with const object property........................ x 708,974,433 ops/sec ±0.09% (194 runs sampled)
object with const null property.......................... x 709,339,584 ops/sec ±0.09% (194 runs sampled)
@Uzlopak this PR looks very interesting, why not keep working on it?