Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
if-else vs switch 545
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0
Browser:
Firefox 128
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Switch case
149437.4 Ops/sec
if-else
147950.0 Ops/sec
Tests:
Switch case
const a = 1; switch (a) { case 5: console.log("a is 5"); break; case 1: console.log("a is 1"); break; }
if-else
const a = 1; if (a == 5) { console.log("a is 5"); } else if (a == 1) { console.log("a is 1"); }