Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
While vs For loop vs Map
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0
Browser:
Chrome 125
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Map loop
20.0M/s
While loop
9.2M/s
For loop
4.8M/s
View exact numbers
Test name
Executions per second
✓
Map loop
20,004,164 Ops/sec
While loop
9,228,352 Ops/sec
For loop
4,804,802 Ops/sec
Script Preparation code:
var acts = "BRA|BRA|FLR|VSL|BRA".split("|");
Tests:
For loop
for (var i = 0; i < acts.length -1; i++) { if (acts[i] == "BRA") acts.splice(i, 1); }
While loop
var i = acts.length; while (i--) { if (acts[i] == "BRA") acts.splice(i, 1); }
Map loop
acts.map((act,i)=>{ if (act == "BRA") acts.splice(i, 1); })