Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Compare JS `for...of` VS `filter` VS `reduce` VS `forEach`
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36
Browser:
Chrome 146
Operating system:
Linux
Device Platform:
Desktop
Date tested:
28 days ago
Test name
Executions per second
for-of
260856.8 Ops/sec
filter
133623.5 Ops/sec
reduce
204856.1 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const data = Array.from({ length: 10000 }, (_, i) => (i < 101 ? -1 : 1)); // Optional: Shuffle to make it realistic // data.sort(() => Math.random() - 0.5);
Tests:
reduce
const count = data.reduce((acc, val) => val < 0 ? acc + 1 : acc, 0);
filter
const count = data.filter(item => item < 0).length;
for...of
let count = 0; for (const item of data) { if (item < 0) { count++; } }
forEach
let count = 0; data.forEach(item => item < 0 && count++);