Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
While vs For Loop - Luigi 3
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0
Browser:
Firefox 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
For loop
18.1 Ops/sec
While loop
18.3 Ops/sec
Tests:
For loop
const size = 1000000 const generateRandomDigit = () => Math.floor(Math.random() * 10) const generateRandomLetter = () => String.fromCharCode(Math.floor(Math.random() * 26) + 65) for (var i = 0; i < size; i++) { generateRandomDigit() generateRandomLetter() }
While loop
const size = 1000000 const generateRandomDigit = () => Math.floor(Math.random() * 10) const generateRandomLetter = () => String.fromCharCode(Math.floor(Math.random() * 26) + 65) let c = 0 do { c++ generateRandomDigit() generateRandomLetter() } while(c <= size)