keyboardchal

JavaScript performance comparison

Revision 2 of this test case created

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Pushing to array
function unShift (s) {
  var sLen, offsetChars, normChars, adjKey, newStringArr=[];
  sLen = s.length;

  keyMap = {'w':'q','e':'w','r':'e','t':'r','y':'t','u':'y','i':'u','o':'i','p':'o','{':'p','s':'a','d':'s','f':'d','g':'f','h':'g','j':'h','k':'j','l':'k',';':'l','x':'z','c':'x','v':'c','b':'v','n':'b','m':'n',',':'m',' ':' ','W':'Q','E':'W','R':'E','T':'R','Y':'T','U':'Y','I':'U','O':'I','P':'O','S':'A','D':'S','F':'D','G':'F','H':'G','J':'H','K':'J','L':'K','X':'Z','C':'X','V':'C','B':'V','N':'B','M':'N'}

  for (var i=0; i <= sLen - 1; i++) {
    adjKey = getAdjKey( s[i] );
    newStringArr.push(adjKey);
  }

  function getAdjKey (inputKey) {
    return keyMap[inputKey]
  }
  return newStringArr.join('');
}

unShift("Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f");
pending…
concat string
function unShift (s) {
  var sLen, offsetChars, normChars, adjKey, newString="", sLen = s.length;

  keyMap = {'w':'q','e':'w','r':'e','t':'r','y':'t','u':'y','i':'u','o':'i','p':'o','{':'p','s':'a','d':'s','f':'d','g':'f','h':'g','j':'h','k':'j','l':'k',';':'l','x':'z','c':'x','v':'c','b':'v','n':'b','m':'n',',':'m',' ':' ','W':'Q','E':'W','R':'E','T':'R','Y':'T','U':'Y','I':'U','O':'I','P':'O','S':'A','D':'S','F':'D','G':'F','H':'G','J':'H','K':'J','L':'K','X':'Z','C':'X','V':'C','B':'V','N':'B','M':'N'}

  for (var i=0; i <= sLen - 1; i++) {
    adjKey = keyMap[ s[i] ];
    newString += adjKey;
  }
  return newString;
}

unShift("Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f");
pending…
regex
function unshiftKeys(input) {
    return input.replace(/./g, function(c) {
        var to   = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        var from = "snvfrghjokl;,mp[wtdyibecuxSNVFRGHJOKL:<MP{WTDYIBECUX";
        return to[from.indexOf(c)] || c;
    });
}

unshiftKeys("Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f Jr;;p ept;f");
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment