Tests:
  • Array.includes

    x
     
    const testStrFirst = 'foo';
    ['foo', 'bar'].includes(testStrFirst);
    const testStrSecond = 'bar';
    ['foo', 'bar'].includes(testStrSecond);
    const testStrNotMatch = 'baz';
    ['foo', 'bar'].includes(testStrNotMatch);
  • String.match

     
    const testStrFirst = 'foo';
    testStrFirst.match(/^(foo|bar)$/);
    const testStrSecond = 'bar';
    testStrSecond.match(/^(foo|bar)$/);
    const testStrNotMatch = 'baz';
    testStrNotMatch.match(/^(foo|bar)$/);
  • Multiple if Conditions

     
    const testStrFirst = 'foo';
    if (testStrFirst == 'foo' || testStrFirst == 'bar') {}
    const testStrSecond = 'bar';
    if (testStrFirst == 'foo' || testStrFirst == 'bar') {}
    const testStrNotMatch = 'baz';
    if (testStrFirst == 'foo' || testStrFirst == 'bar') {}
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Array.includes
    String.match
    Multiple if Conditions

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 26 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Chrome 135 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Array.includes 76279400.0 Ops/sec
String.match 15121363.0 Ops/sec
Multiple if Conditions 187776576.0 Ops/sec