regexp-many-small-one-big (v3)

Revision 3 of this benchmark created on


Setup

const patts = ['^aa', 'bb$', '^cc$', 'd?d', 'e+', 'ff', 'gg', 'hh', 'ii', 'jj']

const regex = patts.map(el => new RegExp(el, 'iu'))

const monster = new RegExp('(?:' + patts.join(')|(?:') + ')', 'iu');

const values = [
'asdbsbhlbfdkjbdsfbdslf dsn fndsbfdsjbffdslfndsklfndsklnfsdnfjkndskfjdklsjbflkjdsbfkjbdsfkljbsdjkfbksdb fjksbdfjbsdbfjdsbfkjsdbjkfbdsjkfbsdjbfjsdbfjkdsbfjk sdfkj sdh cjksdncknsdcklsndcndskjncsdk csmd kjdscklnsd ajfn f clks dfscfdsncf;ls;',
'00',
'aa',
'bb',
'cc',
'dd',
'ee',
'ff',
'gg',
'hh',
'ii',
'jj',
'100',
'1aa',
'1bb',
'1cc',
'1dd',
'1ee',
'1ff',
'1gg',
'1hh',
'1ii',
'1jj',
'009',
'aa9',
'bb9',
'cc9',
'dd9',
'ee9',
'ff9',
'gg9',
'hh9',
'ii9',
'jj9',
'1009',
'1aa9',
'1bb9',
'1cc9',
'1dd9',
'1ee9',
'1ff9',
'1gg9',
'1hh9',
'1ii9',
'1jj9',
'00',
'aa',
'bb',
'cc',
'dd',
'ee',
'ff',
'gg',
'hh',
'ii',
'jj',
'100',
'1aa',
'1bb',
'1cc',
'1dd',
'1ee',
'1ff',
'1gg',
'1hh',
'1ii',
'1jj',
'009',
'aa9',
'bb9',
'cc9',
'dd9',
'ee9',
'ff9',
'gg9',
'hh9',
'ii9',
'jj9',
'1009',
'1aa9',
'1bb9',
'1cc9',
'1dd9',
'1ee9',
'1ff9',
'1gg9',
'1hh9',
'1ii9',
'1jj9',
]

let acc1 = 0
let acc2 = 0

Teardown

console.log({acc1, acc2})

Test runner

Ready to run.

Testing in
TestOps/sec
many-small

for(const val of values) {
 if (regex.some(exp => exp.test(val))) acc1 ++;
}
ready
one-big

for(const val of values) {
  if (monster.test(val)) acc2 ++;
}

ready

Revisions

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