Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
string match in list: if condition vs array.includes
(version: 1)
Comparing performance of:
switch case vs array.includes
Created:
one year ago
by:
Guest
Go to the latest result
Tests:
switch case
((v) => { if ( v === 'asdpopqnf' && v === 'zbvxcvuud' && v === 'qwtewoiru' && v === 'pojfopdgd' && v === 'tuunreiro' ) { return true; } return false; })('tuunreiro')
array.includes
((v) => { return [ 'asdpopqnf', 'zbvxcvuud', 'qwtewoiru', 'pojfopdgd', 'tuunreiro' ].includes(v); })('tuunreiro')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
switch case
array.includes
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser/OS:
Chrome 137 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
switch case
93.7M/s
array.includes
51.0M/s
View exact numbers
Test name
Executions per second
✓
switch case
93,700,992 Ops/sec
array.includes
50,987,800 Ops/sec
Related benchmarks
switch vs if else vs do while vs object
Switch true vs if else
if else vs switch case vs indexOf 2
string match in list: switch case vs array.includes
string match in list: array.includes vs if condition ||
string match in list: array.includes vs if &&
Comments
Confirm delete:
Do you really want to delete benchmark?