Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
if-else vs switch 545
(version: 1)
Comparing performance of:
Switch case vs if-else
Created:
one year ago
by:
Guest
Jump to the latest result
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"); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Switch case
if-else
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0
Browser/OS:
Firefox 128 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Switch case
149437.4 Ops/sec
if-else
147950.0 Ops/sec
Comments
Confirm delete:
Do you really want to delete benchmark?