single-char-lookup

Benchmark created on


Setup

function arr(x) {
        return ['a', 'b', 'c', 'd', 'e', 'x', 'y', 'z'].indexOf(x) > -1;
    }
    
    function str(x) {
        return 'abcdexyz'.indexOf(x) > -1;
    }
    
    function reg(x) {
        return x.match(/^[abcdexyz]$/) !== null;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
array
arr('a');
arr('z');
arr('q');
ready
str
str('a');
str('z');
str('q');
ready
reg
reg('a');
reg('z');
reg('q');
ready

Revisions

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