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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Sum with 8-bit array and loop
41872.2 Ops/sec
Sum with standard array and reduce
19345.9 Ops/sec
Sum with standard array and loop
34598.2 Ops/sec
Sum with 8-bit array and reduce
7714.0 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)