Test chars

Benchmark created on


Preparation HTML

<script>
const str = 'a-b.c_d';
const compiledRegexp = new RegExp('[_.-]');
const testChars = new Set(['_', '.', '-']);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Regexp
for (let i = 0; i < 1000; i++) {
	for (let char of str) {
		/[_.-]/.test(char);	
	}
}
ready
Compiled regexp
for (let i = 0; i < 1000; i++) {
	for (let char of str) {
		compiledRegexp.test(char);
	}
}
ready
Set.has
for (let i = 0; i < 1000; i++) {
	for (let char of str) {
		testChars.has(char);
	}
}
ready

Revisions

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