Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array constructor vs literal performance - 100000 items
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/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Array constructor - 100000 items
593.7 Ops/sec
Array literal - 100000 items
543.9 Ops/sec
Array literal (assign by index) - 100000 items
596.4 Ops/sec
Array literal (explicit length) - 100000 items
596.7 Ops/sec
Script Preparation code:
var n = 10000; function Person(name, age) { this.name = name; this.age = age; }
Tests:
Array constructor - 100000 items
var arr = new Array(n); for (var i = 0; i < n; i++) { arr[i] = new Person(i + '', i); }
Array literal - 100000 items
var arr = []; for (var i = 0; i < n; i++) { arr.push(new Person(i + '', i)); }
Array literal (assign by index) - 100000 items
var arr = []; for (var i = 0; i < n; i++) { arr[i] = new Person(i + '', i); }
Array literal (explicit length) - 100000 items
var arr = []; arr.length = n; for (var i = 0; i < n; i++) { arr[i] = new Person(i + '', i); }