Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
array vs obj
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/135.0.0.0 Safari/537.36
Browser:
Chrome 135
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
array
952135.9 Ops/sec
object
124880.0 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/lodash/4.16.0/lodash.min.js"></script>
Script Preparation code:
var data1 = []; for (let i = 0; i < 1000; i++) { data1.push({ val1: Math.random() * 100, val2: Math.random() * 100 }); } var data2 = []; for (let i = 0; i < 1000; i++) { data2.push([ Math.random() * 100, Math.random() * 100 ]); } const avgBy = (fn, arr) => arr.reduce((sum, obj) => sum + fn(obj), 0) / arr.length;
Tests:
array
avgBy((obj) => obj[0], data2)
object
avgBy((obj) => obj.val1, data1)