Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array vs TypedArray write performance %%%%%%%%%%%% nested
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:146.0) Gecko/20100101 Firefox/146.0
Browser:
Firefox 146
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
4 months ago
Test name
Executions per second
Array write
116020.0 Ops/sec
TypedArray write
165924.2 Ops/sec
Matrix write
42363.2 Ops/sec
Nested write
81756.8 Ops/sec
Map write
42386.0 Ops/sec
Script Preparation code:
var array = new Array(10000).fill(1) var typedArray = new Uint32Array(10000).fill(1); var nested = new Array(100).fill(new Array(100).fill(1)) var matrix = {size:100, data:typedArray, get(x,y){return this.data[x*this.size+y]}, set(x,y,v){this.data[x*this.size+y]=v}, map(c){ const data = this.data; const size = this.size; for (let x=0; x<100; x++) { for (let y=0; y<100; y++) { const index = x*size+y data[index] = c(x,y, data[index]); } } }}
Tests:
Array write
for (let x=0; x<100; x++) { for (let y=0; y<100; y++) { array[x*100+y] += 1; } }
TypedArray write
for (let x=0; x<100; x++) { for (let y=0; y<100; y++) { typedArray[x*100+y] += 1; } }
Matrix write
for (let x=0; x<100; x++) { for (let y=0; y<100; y++) { matrix.set(x, y, matrix.get(x,y) +1); } }
Nested write
for (let x=0; x<100; x++) { for (let y=0; y<100; y++) { nested[x][y] += 1 } }
Map write
matrix.map((_,__,v)=>v+1)