Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Array constructor - 100000 items
2K/s
Array literal (explicit length) - 100000 items
2K/s
Array literal (assign by index) - 100000 items
2K/s
Array literal - 100000 items
2K/s
View exact numbers
Test name
Executions per second
✓
Array constructor - 100000 items
2,040 Ops/sec
Array literal (explicit length) - 100000 items
1,995 Ops/sec
Array literal (assign by index) - 100000 items
1,945 Ops/sec
Array literal - 100000 items
1,939 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); }