Test case insesitive

Benchmark created on


Setup

function isInterfaceNameValidToLowerCase(name) {
  const lcName = name.toLowerCase();
  return lcName.indexOf('ethernet') >= 0 || lcName.indexOf('vlan') >= 0;
}

const regEx = new RegExp(/ethernet|vlan/, "i");

function isInterfaceNameValidRegEx(name) {
 return regEx.test(name);
}

Test runner

Ready to run.

Testing in
TestOps/sec
With toLowercase & indexof
isInterfaceNameValidToLowerCase("Vxlan1")
isInterfaceNameValidToLowerCase("Ethernet1")
isInterfaceNameValidToLowerCase("Vlan1")
isInterfaceNameValidToLowerCase("vxlan1")
isInterfaceNameValidToLowerCase("ethernet1")
isInterfaceNameValidToLowerCase("vlan1")
ready
With RegEx
isInterfaceNameValidRegEx("Vxlan")
isInterfaceNameValidRegEx("Ethernet1")
isInterfaceNameValidRegEx("Vlan1")
isInterfaceNameValidRegEx("vxlan")
isInterfaceNameValidRegEx("ethernet1")
isInterfaceNameValidRegEx("vlan1")
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.