Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
sum with typed int array vs standard array
testing performance of type arrays vs standard arrays
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Sum with 16-bit array and loop
87659.8 Ops/sec
Sum with standard array and reduce
12308.9 Ops/sec
Sum with standard array and loop
16043.6 Ops/sec
Sum with 16-bit array and reduce
6839.9 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
function sumWithReduce(arr) { return arr.reduce((x, y) => (y = +y) ? x + y: x, 0) } function sumWithReduceInt16(arr) { return arr.reduce((x, y) => x + y, 0) } function sumWithLoop(arr) { let length = arr.length; let init = 0; let val; while (length--) if (val = +arr[length]) init += val; return init; } function sumWithLoopInt16(arr) { let length = arr.length; let init = 0; let val; while (length--) init += val; return init; } const nums = Array.from({length: 10000}, () => Math.floor(Math.random() * 65536)) // throw in some non numbers nums[4] = '5'; nums[22] = NaN; // coerces non numbers to zero const numsInt = new Uint16Array(nums);
Tests:
Sum with 16-bit array and loop
sumWithLoopInt16(numsInt)
Sum with standard array and reduce
sumWithReduce(nums)
Sum with standard array and loop
sumWithLoop(nums)
Sum with 16-bit array and reduce
sumWithReduceInt16(numsInt)