Regex Vs endsWith

Benchmark created on


Setup

const arr = new Array(100000).fill('Helloworld.index.tsx');
const regexMap = (key) => /index\.(jsx|tsx|mdx)$/.test(key);
const endsWith = (key) => key.endsWith('index.jsx') || key.endsWith('index.tsx') || key.endsWith('index.mdx');

Test runner

Ready to run.

Testing in
TestOps/sec
Regex
const res = arr.map(regexMap)

ready
endsWith
const res = arr.map(endsWith)
ready

Revisions

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