Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array Fill comparison
Comparison with different methods of Array Fill, to avoid object reference.
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/122.0.0.0 Safari/537.36
Browser:
Chrome 122
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Array fill (has reference issues)
1323734.5 Ops/sec
Array from
61194.2 Ops/sec
Array map
50682.3 Ops/sec
For and push
27774.6 Ops/sec
Array spread operator
50730.7 Ops/sec
HTML Preparation code:
<div id=''></div>
Script Preparation code:
var ARRAY_SIZE = 250; var createSampleObject = function() { return { "id": 538, "uid": "9b14d2b5-a0c5-409d-a8bf-4b569a5ce10b", "vin": "54A1LF7KKBT858198", "make_and_model": "Honda Odyssey", "color": "Violet", "transmission": "Automatic", "drive_type": "RWD", "fuel_type": "Ethanol", "car_type": "Regular Cab Pickup", "car_options": [ "Rear Window Defroster", "MP3 (Single Disc)", "Airbag: Driver", "CD (Multi Disc)", "Alloy Wheels", "Cruise Control", "Rear Window Wiper", "MP3 (Multi Disc)", "Power Locks" ], "specs": [ "Bright pedals", "Immobilizer system", "Pwr accessory delay", "Enhanced accident response system unlocks the doors, shuts off the fuel pump and turns on interior lights after airbag deploys", "Carpeted cargo area", "Floor carpeting", "Black windshield molding", "Optitron electroluminescent instrumentation" ], "doors": 2, "mileage": 16246, "kilometrage": 86360, "license_plate": "DQX-9667" } };
Tests:
Array fill (has reference issues)
new Array(ARRAY_SIZE).fill(createSampleObject());
Array from
Array.from({ length: ARRAY_SIZE }, createSampleObject);
Array map
new Array(ARRAY_SIZE).fill().map(() => createSampleObject() );
For and push
const arr = []; for (let i = 0; i < ARRAY_SIZE; i++) { arr.push(createSampleObject()); }
Array spread operator
[...new Array(ARRAY_SIZE)].map(() => createSampleObject());