Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
MinMax test
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
Benchmark engine:
Benchmark.js
foreach
64K/s
forof
57K/s
for
44K/s
forin
35K/s
View exact numbers
Test name
Executions per second
✓
foreach
64,283 Ops/sec
forof
57,333 Ops/sec
for
44,288 Ops/sec
forin
34,574 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; }