Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
For Loop VS Filter Map
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/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
For Loop
3954662.0 Ops/sec
Filter Map
8286597.5 Ops/sec
Script Preparation code:
var existingEarningIds = []; var existingEarnings = [ { earningAllocation: 50, prospectId: "1", earningAllocationId: "1", prospectName: "Dummy", }, { earningAllocation: 50, prospectId: "2", earningAllocationId: "2", prospectName: "Dummy", }, { earningAllocation: 50, prospectId: "3", earningAllocationId: "3", prospectName: "Dummy", },{ earningAllocation: 50, prospectId: "4", earningAllocationId: "4", prospectName: "Dummy", },{ earningAllocation: 50, prospectId: "5", earningAllocationId: "5", prospectName: "Dummy", } ]
Tests:
For Loop
for (const earning of existingEarnings || []) { if (earning.earningAllocationId) { existingEarningIds.push(earning.earningAllocationId); } }
Filter Map
existingEarningIds = (existingEarnings || []) .filter(earning => earning.earningAllocationId) .map(earning => earning.earningAllocationId);