Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
switch vs if
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0
Browser:
Firefox 143
Operating system:
Windows
Device Platform:
Desktop
Date tested:
11 months ago
switch
42.2M/s
if
37.1M/s
View exact numbers
Test name
Executions per second
✓
switch
42,150,480 Ops/sec
if
37,148,368 Ops/sec
HTML Preparation code:
<div class="test"></div>
Script Preparation code:
var v = 8;
Tests:
switch
switch (true) { case v === 1: break; case v === 2: break; case v === 3: break; case v === 4: break; case v === 5: break; case v === 6: break; case v === 7: break; default: ; }
if
if (v === 1) { } else if (v === 2) { } else if (v === 3) { } else if (v === 4) { } else if (v === 5) { } else if (v === 6) { } else if (v === 7) { } else if (v === 8) { } else { }