Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
For loop, length, spread set vs For of
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/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Const length
298/s
For loop
288/s
For of
278/s
View exact numbers
Test name
Executions per second
✓
Const length
298 Ops/sec
For loop
288 Ops/sec
For of
278 Ops/sec
Script Preparation code:
var set = new Set(Array.from(Array(1000).keys()) .map((x) => `item--${x}`))
Tests:
For of
for (var val of set) { console.log(val); }
Const length
const arr = [...set] let length = arr.length for (let i = 0; i < length; i++) { console.log(arr[i]) }
For loop
const arr = [...set] for (let i = 0; i < arr.length; i++) { console.log(arr[i]) }