Closed noscripter closed 10 months ago
Benchmark result of the ternary operator change commit:
main
)This yields a nice little bump in performance, or otherwise remains flat. The following benchmarks were ran on my 2021 MacBook Pro 14-inch with an M1 Pro chip running macOS Sonoma (14.2.1):
Thanks for this @noscripter, it's a nice little cleanup.
Benchmarks
``` classnames git:(refactor) npm run bench > classnames@2.5.1 bench > node ./benchmarks/run.js (node:95772) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time (Use `node --trace-warnings ...` to show where the warning was created) Benchmarking 'strings'. | Task Name | ops/sec | Average Time (ns) | Margin | Samples | | ------------- | ---------- | ------------------ | ------ | ------- | | default/local | 12,902,063 | 77.50698016049525 | ±0.94% | 6451032 | | default/npm | 15,087,679 | 66.27924267843498 | ±0.54% | 7543841 | | bind/local | 12,459,259 | 80.26158996638294 | ±0.81% | 6229630 | | bind/npm | 13,227,651 | 75.59920808713574 | ±2.60% | 6613827 | | dedupe/local | 4,725,515 | 211.61713059370376 | ±1.50% | 2362758 | | dedupe/npm | 3,741,350 | 267.28317406534336 | ±1.67% | 1870676 | Benchmarking 'object'. | Task Name | ops/sec | Average Time (ns) | Margin | Samples | | ------------- | ---------- | ----------------- | ------ | ------- | | default/local | 15,597,085 | 64.11454419143709 | ±1.31% | 7798543 | | default/npm | 15,509,932 | 64.47481349973197 | ±0.72% | 7754967 | | bind/local | 12,698,498 | 78.74946588230175 | ±1.03% | 6349250 | | bind/npm | 14,696,484 | 68.04348418880458 | ±1.47% | 7348243 | | dedupe/local | 9,326,803 | 107.2178640931543 | ±2.39% | 4663402 | | dedupe/npm | 6,130,380 | 163.1220093357168 | ±8.92% | 3065191 | Benchmarking 'strings, object'. | Task Name | ops/sec | Average Time (ns) | Margin | Samples | | ------------- | ---------- | ------------------ | ------ | ------- | | default/local | 12,227,576 | 81.78235224309321 | ±0.54% | 6113789 | | default/npm | 12,169,374 | 82.17349074400097 | ±0.83% | 6084688 | | bind/local | 10,086,583 | 99.1416002363269 | ±1.08% | 5043292 | | bind/npm | 11,379,709 | 87.87570587262846 | ±1.35% | 5689855 | | dedupe/local | 5,210,441 | 191.92232548319953 | ±0.43% | 2605221 | | dedupe/npm | 3,718,235 | 268.94478723254747 | ±2.45% | 1859118 | Benchmarking 'mix'. | Task Name | ops/sec | Average Time (ns) | Margin | Samples | | ------------- | --------- | ------------------ | ------- | ------- | | default/local | 6,273,738 | 159.39459539429376 | ±10.83% | 3136870 | | default/npm | 7,174,549 | 139.3815734381775 | ±0.51% | 3587275 | | bind/local | 5,776,720 | 173.10859353390987 | ±0.58% | 2888361 | | bind/npm | 6,528,800 | 153.16749138869034 | ±0.77% | 3264401 | | dedupe/local | 2,047,216 | 488.468106880368 | ±1.20% | 1023609 | | dedupe/npm | 1,789,916 | 558.6852887845175 | ±1.15% | 894959 | Benchmarking 'arrays'. | Task Name | ops/sec | Average Time (ns) | Margin | Samples | | ------------- | --------- | ------------------ | ------ | ------- | | default/local | 4,772,370 | 209.53945889482438 | ±0.84% | 2386186 | | default/npm | 4,988,038 | 200.47960598770234 | ±0.53% | 2494020 | | bind/local | 3,764,922 | 265.60971763127566 | ±0.62% | 1882462 | | bind/npm | 4,576,970 | 218.48513050245984 | ±0.78% | 2288486 | | dedupe/local | 2,132,913 | 468.84235318509957 | ±0.65% | 1066457 | | dedupe/npm | 1,870,374 | 534.6521433531376 | ±0.74% | 935188 | Finished! ```