Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
if-else vs switch short
(version: 1)
Comparing performance of:
Switch case vs if-else
Created:
11 months 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 4: console.log("a is 4"); break; }
if-else
const a = 1; if (a == 5) { console.log("a is 5"); } else if (a == 4) { console.log("a is 4"); }
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:
11 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:139.0) Gecko/20100101 Firefox/139.0
Browser/OS:
Firefox 139 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Switch case
1912152704.0 Ops/sec
if-else
1894847104.0 Ops/sec
Related benchmarks:
if-else vs switch
if-else vs switch v2
if-else vs switch case
if-else vs switch vs if
if-else vs switch test
if/switch1
if-else vs switch22
if-else vs switch4
if-else vs switch test 1
Comments
Confirm delete:
Do you really want to delete benchmark?