Last active
March 12, 2026 16:41
-
-
Save lppedd/b5d323300c6b8044c7d0149bfd564eb2 to your computer and use it in GitHub Desktop.
TypedArray benchmarks results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TL;DR: to me it makes sense to go with the PR changes. Overall it performs better. | |
| Observations: | |
| 1. Performance changes depending on the benchmark function order. | |
| This tells me my workstation's CPU is being throttled after a while as the benchmark takes quite some time. | |
| 2. If I execute single cases independently (e.g., only 100, only 1000, only 15000, etc.) | |
| the TypedArray.set/slice is always more performant. The benchmark function order does not matter anymore. | |
| You can see this behavior in the "focused" benchmarks below. | |
| 3. The fillFrom variant actually got better from Node.js 20, it is much closer now. | |
| 4. The bigger the array is, the closer the difference becomes. Strange... | |
| I'd have expected TypedArray.set to be more performant for huge arrays. Maybe it's how memory is copied that makes it slower? | |
| Edit: well this isn't really exact. | |
| So, the difference is closer as the target array gets bigger (while the source is still 10k elements), | |
| but what we're seeing is probably memory allocation time. | |
| If instead we make the source array bigger (e.g., 100k instead of 10k), the perf difference is quite in favor | |
| of the set/slice optimization. | |
| Bun benchmarks at the very end btw. Observation is that the loop variant is less optmized than V8's one, | |
| so set/slice tend to perform better. | |
| - Focused ByteArray | |
| Benchmark (newSize) Mode Cnt Score Error Units | |
| ByteArrayBenchmark.fillFrom 15 thrpt 4 27628638.169 ± 2404797.781 ops/sec | |
| ByteArrayBenchmark.fillFrom 100000 thrpt 4 61769.004 ± 1006.888 ops/sec | |
| ByteArrayBenchmark.typedArraySet 15 thrpt 4 28671124.185 ± 586901.091 ops/sec | |
| ByteArrayBenchmark.typedArraySet 100000 thrpt 4 90635.169 ± 1063.528 ops/sec | |
| - Focused DoubleArray | |
| Benchmark (newSize) Mode Cnt Score Error Units | |
| DoubleArrayBenchmark.fillFrom 100 thrpt 4 2820342.467 ± 21281.116 ops/sec | |
| DoubleArrayBenchmark.fillFrom 100000 thrpt 4 14107.813 ± 270.577 ops/sec | |
| DoubleArrayBenchmark.typedArraySet 100 thrpt 4 2970674.197 ± 47295.056 ops/sec | |
| DoubleArrayBenchmark.typedArraySet 100000 thrpt 4 12965.521 ± 107.205 ops/sec | |
| Benchmark (newSize) Mode Cnt Score Error Units | |
| DoubleArrayBenchmark.fillFrom 100000 thrpt 4 14833.906 ± 88.319 ops/sec | |
| DoubleArrayBenchmark.typedArraySet 100000 thrpt 4 15576.304 ± 171.485 ops/sec | |
| - ByteArray (fillFrom / typedArraySet) | |
| Benchmark (newSize) Mode Cnt Score Error Units | |
| ByteArrayBenchmark.fillFrom 15 thrpt 4 34005735.777 ± 1028748.449 ops/sec | |
| ByteArrayBenchmark.fillFrom 100 thrpt 4 3395904.274 ± 38950.870 ops/sec | |
| ByteArrayBenchmark.fillFrom 1000 thrpt 4 1251540.158 ± 4985.645 ops/sec | |
| ByteArrayBenchmark.fillFrom 5000 thrpt 4 296820.609 ± 8317.182 ops/sec | |
| ByteArrayBenchmark.fillFrom 15000 thrpt 4 133172.196 ± 3150.702 ops/sec | |
| ByteArrayBenchmark.fillFrom 100000 thrpt 4 55852.070 ± 305.085 ops/sec | |
| ByteArrayBenchmark.fillFrom 1000000 thrpt 4 10599.035 ± 50.108 ops/sec | |
| ByteArrayBenchmark.typedArraySet 15 thrpt 4 27102762.886 ± 1706757.692 ops/sec | |
| ByteArrayBenchmark.typedArraySet 100 thrpt 4 3251302.562 ± 34177.937 ops/sec | |
| ByteArrayBenchmark.typedArraySet 1000 thrpt 4 2463474.791 ± 22089.692 ops/sec | |
| ByteArrayBenchmark.typedArraySet 5000 thrpt 4 1065110.895 ± 22271.781 ops/sec | |
| ByteArrayBenchmark.typedArraySet 15000 thrpt 4 464796.898 ± 8917.247 ops/sec | |
| ByteArrayBenchmark.typedArraySet 100000 thrpt 4 48291.591 ± 339.110 ops/sec | |
| ByteArrayBenchmark.typedArraySet 1000000 thrpt 4 9901.397 ± 6.658 ops/sec | |
| - ByteArray (typedArraySet / fillFrom) | |
| Benchmark (newSize) Mode Cnt Score Error Units | |
| ByteArrayBenchmark.atypedArraySet 15 thrpt 4 33757130.991 ± 333922.161 ops/sec | |
| ByteArrayBenchmark.atypedArraySet 100 thrpt 4 3420329.377 ± 123116.553 ops/sec | |
| ByteArrayBenchmark.atypedArraySet 1000 thrpt 4 2771159.349 ± 15299.339 ops/sec | |
| ByteArrayBenchmark.atypedArraySet 5000 thrpt 4 1098089.057 ± 16200.108 ops/sec | |
| ByteArrayBenchmark.atypedArraySet 15000 thrpt 4 472013.287 ± 9148.361 ops/sec | |
| ByteArrayBenchmark.atypedArraySet 100000 thrpt 4 74377.238 ± 3138.902 ops/sec | |
| ByteArrayBenchmark.atypedArraySet 1000000 thrpt 4 11199.787 ± 214.996 ops/sec | |
| ByteArrayBenchmark.bfillFrom 15 thrpt 4 28209124.937 ± 682410.806 ops/sec | |
| ByteArrayBenchmark.bfillFrom 100 thrpt 4 3022150.163 ± 28505.589 ops/sec | |
| ByteArrayBenchmark.bfillFrom 1000 thrpt 4 1101553.096 ± 13295.267 ops/sec | |
| ByteArrayBenchmark.bfillFrom 5000 thrpt 4 270235.646 ± 3747.654 ops/sec | |
| ByteArrayBenchmark.bfillFrom 15000 thrpt 4 129559.001 ± 1179.016 ops/sec | |
| ByteArrayBenchmark.bfillFrom 100000 thrpt 4 39817.013 ± 687.725 ops/sec | |
| ByteArrayBenchmark.bfillFrom 1000000 thrpt 4 9886.106 ± 102.306 ops/sec | |
| - CharArray (fillFrom / typedArraySet) | |
| Benchmark (newSize) Mode Cnt Score Error Units | |
| CharArrayBenchmark.fillFrom 15 thrpt 4 28718065.093 ± 384590.210 ops/sec | |
| CharArrayBenchmark.fillFrom 100 thrpt 4 3006649.809 ± 54629.581 ops/sec | |
| CharArrayBenchmark.fillFrom 1000 thrpt 4 963339.899 ± 11011.081 ops/sec | |
| CharArrayBenchmark.fillFrom 5000 thrpt 4 240979.742 ± 2667.401 ops/sec | |
| CharArrayBenchmark.fillFrom 15000 thrpt 4 97143.159 ± 1114.979 ops/sec | |
| CharArrayBenchmark.fillFrom 100000 thrpt 4 40337.353 ± 295.325 ops/sec | |
| CharArrayBenchmark.fillFrom 1000000 thrpt 4 31999.113 ± 379.819 ops/sec | |
| CharArrayBenchmark.typedArraySet 15 thrpt 4 27414700.783 ± 1317370.091 ops/sec | |
| CharArrayBenchmark.typedArraySet 100 thrpt 4 2770445.595 ± 20122.447 ops/sec | |
| CharArrayBenchmark.typedArraySet 1000 thrpt 4 1817284.634 ± 9437.376 ops/sec | |
| CharArrayBenchmark.typedArraySet 5000 thrpt 4 680112.090 ± 4280.072 ops/sec | |
| CharArrayBenchmark.typedArraySet 15000 thrpt 4 136687.128 ± 2583.341 ops/sec | |
| CharArrayBenchmark.typedArraySet 100000 thrpt 4 41221.547 ± 270.001 ops/sec | |
| CharArrayBenchmark.typedArraySet 1000000 thrpt 4 33473.172 ± 366.509 ops/sec | |
| - CharArray (typedArraySet / fillFrom) | |
| Benchmark (newSize) Mode Cnt Score Error Units | |
| CharArrayBenchmark.atypedArraySet 15 thrpt 4 29397540.906 ± 247547.243 ops/sec | |
| CharArrayBenchmark.atypedArraySet 100 thrpt 4 3518954.651 ± 15972.135 ops/sec | |
| CharArrayBenchmark.atypedArraySet 1000 thrpt 4 1923247.797 ± 21380.572 ops/sec | |
| CharArrayBenchmark.atypedArraySet 5000 thrpt 4 673658.233 ± 7794.471 ops/sec | |
| CharArrayBenchmark.atypedArraySet 15000 thrpt 4 187375.678 ± 1499.564 ops/sec | |
| CharArrayBenchmark.atypedArraySet 100000 thrpt 4 45004.083 ± 221.442 ops/sec | |
| CharArrayBenchmark.atypedArraySet 1000000 thrpt 4 32926.084 ± 1051.118 ops/sec | |
| CharArrayBenchmark.bfillFrom 15 thrpt 4 28309107.543 ± 874443.028 ops/sec | |
| CharArrayBenchmark.bfillFrom 100 thrpt 4 2932758.184 ± 31520.034 ops/sec | |
| CharArrayBenchmark.bfillFrom 1000 thrpt 4 929891.887 ± 2000.617 ops/sec | |
| CharArrayBenchmark.bfillFrom 5000 thrpt 4 234631.896 ± 4324.301 ops/sec | |
| CharArrayBenchmark.bfillFrom 15000 thrpt 4 84831.542 ± 919.072 ops/sec | |
| CharArrayBenchmark.bfillFrom 100000 thrpt 4 31818.922 ± 318.705 ops/sec | |
| CharArrayBenchmark.bfillFrom 1000000 thrpt 4 31392.925 ± 159.631 ops/sec | |
| Bun: | |
| - ByteArray | |
| Benchmark (newSize) Mode Cnt Score Error Units | |
| ByteArrayBenchmark.fillFrom 15 thrpt 4 57616259.793 ± 766115.226 ops/sec | |
| ByteArrayBenchmark.fillFrom 1000 thrpt 4 1462226.983 ± 12415.122 ops/sec | |
| ByteArrayBenchmark.fillFrom 1000000 thrpt 4 10513.409 ± 55.734 ops/sec | |
| ByteArrayBenchmark.typedArraySet 15 thrpt 4 48750741.707 ± 34095.383 ops/sec | |
| ByteArrayBenchmark.typedArraySet 1000 thrpt 4 7073100.674 ± 95326.235 ops/sec | |
| ByteArrayBenchmark.typedArraySet 1000000 thrpt 4 12160.176 ± 24.909 ops/sec | |
| - FloatArray | |
| Benchmark (newSize) Mode Cnt Score Error Units | |
| FloatArrayBenchmark.fillFrom 1000 thrpt 4 1200318.198 ± 18196.418 ops/sec | |
| FloatArrayBenchmark.fillFrom 15000 thrpt 4 95275.033 ± 971.608 ops/sec | |
| FloatArrayBenchmark.fillFrom 1000000 thrpt 4 3187.939 ± 19.522 ops/sec | |
| FloatArrayBenchmark.typedArraySet 1000 thrpt 4 2517279.471 ± 19436.060 ops/sec | |
| FloatArrayBenchmark.typedArraySet 15000 thrpt 4 174688.506 ± 580.972 ops/sec | |
| FloatArrayBenchmark.typedArraySet 1000000 thrpt 4 3426.756 ± 30.148 ops/sec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment