griffel

Benchmark created on


Setup

const DEBUG_RESET_CLASSES = {
	f16th3vw: true,
	frdkuqy0: true,
	fat0sn40: true,
	fjseox00: true,
};

const DEFINITION_LOOKUP_TABLE = {
	abc0: [],
	abc1: [],
	abc2: [],
	abc3: [],
	abc4: [],
	abc5: [],
	abc6: [],
	abc7: [],
	abc8: [],
	abc9: [],
	abc10: [],
	abc11: [],
	abc12: [],
	abc13: [],
	abc14: [],
	abc15: [],
	abc16: [],
	abc17: [],
	abc18: [],
	abc19: [],
	abc20: [],
	__1qdh4ig: [],
	abc21: [],
	abc22: [],
	abc23: [],
	abc24: [],
	abc25: [],
	abc26: [],
	abc27: [],
	abc28: [],
	abc29: [],
	abc30: [],
	abc31: [],
	abc32: [],
	abc33: [],
	abc34: [],
	abc35: [],
	abc36: [],
	abc37: [],
	abc38: [],
	abc39: [],
	abc40: [],
	abc41: [],
	abc42: [],
	abc43: [],
	abc44: [],
	abc45: [],
	abc46: [],
	abc47: [],
	abc48: [],
	abc49: [],
	abc50: [],
	abc51: [],
	abc52: [],
	abc53: [],
	abc54: [],
	abc55: [],
	abc56: [],
	abc57: [],
	abc58: [],
	abc59: [],
	abc60: [],
	abc61: [],
	abc62: [],
	abc63: [],
	abc64: [],
	abc65: [],
}

const lookupRegex = () => {
	const definitionKeys = Object.keys({ ...DEFINITION_LOOKUP_TABLE, ...DEBUG_RESET_CLASSES });

	if (definitionKeys.length) {
		return new RegExp(`${definitionKeys.join('|')}`, 'g');
	}

	return undefined;
};

const val = "asdf 123 __1qdh4ig"
 

Test runner

Ready to run.

Testing in
TestOps/sec
useRegex
if (typeof val === 'string') {
	return lookupRegex()?.test(val) ?? false;
}
ready
useSplit
if (typeof val === 'string') {
	return val.split(' ').find(v => DEBUG_RESET_CLASSES[v] || DEFINITION_LOOKUP_TABLE[v])
}
ready

Revisions

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