Let's compare

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
RE
const externalIconRE = /^(data:image|edge:|http(s?):)/;
const name = 'https://www.microsoft.com'

if (externalIconRE.test(name )) {
	console.log('===========')
}
ready
Set.has() + indexOf() + substring()
const set = new Set([
    'data:image', // Base64-encoded string
    'edge:',
    'https:',
    'http:',
  ]);
const name = 'https://www.microsoft.com'

const prefix = name.indexOf('/');
if (prefix != -1 && set.has(name.substring(0, prefix))) {
	console.log('===========')
}
 
ready

Revisions

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