Many regexes vs grouped regexes

Benchmark created on


Setup

const regexList = [
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
	/(.*)\/foo\/(.*)/,
];

const regexGroup = /(.*)\/(foo1)?(foo2)?(foo3)?(foo4)?(foo5)?(foo6)?(foo7)?(foo8)?(foo9)?(foo10)?(foo11)?(foo12)?(foo13)?(foo14)?(foo15)?(foo16)?(foo17)?(foo18)?(foo19)?(foo20)?(foo21)?(foo22)?(foo23)?(foo24)?(foo25)?(foo26)?\/(.*)/;

Test runner

Ready to run.

Testing in
TestOps/sec
Iterate regex list
regexList.forEach((r) => r.test('https://www-apetitonline-cz.translate.goog/recept/taquitos-s-trhanym-veprovym?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-GB/foo18/'))
ready
Grouped regex
regexGroup.test('https://www-apetitonline-cz.translate.goog/recept/taquitos-s-trhanym-veprovym?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-GB/foo18/')
ready

Revisions

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