Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
MinMax test
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15
Browser:
Safari 17
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
for
47147.0 Ops/sec
foreach
63949.6 Ops/sec
forin
43204.8 Ops/sec
forof
68500.0 Ops/sec
Script Preparation code:
var arrays = []; var range = {min:0,max:0}; for (let i = 0; i < 100; i++) { arrays.push({ name: 'asdf', price: Math.random() * (10000 - 1000) + 1000 }) }
Tests:
for
for (let i = 0; i < 100; i++) { const price = arrays[i].price; if (price < range.min) range.min = price; else if (price > range.max) range.max = price; }
foreach
arrays.forEach((obj)=>{ const price = obj.price; if (price < range.min) range.min = price; else if (price > range.max) range.max = price; })
forin
for (const i in arrays){ const price = arrays[i].price; if (price < range.min) range.min = price; else if (price > range.max) range.max = price; }
forof
for (const obj of arrays){ const price = obj.price; if (price < range.min) range.min = price; else if (price > range.max) range.max = price; }