Tests:
  • FCC

    x
     
    function rot13(str) {
      return str.split('')
        .map.call(str, function(char) {
          x = char.charCodeAt(0);
          if (x < 65 || x > 90) {
            return String.fromCharCode(x);
          }
          else if (x < 78) {
            return String.fromCharCode(x + 13);
          }
          return String.fromCharCode(x - 13);
        }).join('');
    }
    rot13("SERR PBQR PNZC");
  • self

     
    function rot13(str) { // LBH QVQ VG!
      var decode = [];
      var decodeString = "";
      for (i = 0; i < str.length; i++) {
        decode.push(str.charCodeAt(i));
        if (decode[i] >= 78 && decode[i] <= 90) {
          decode[i] = decode[i] - 13;
        } else if (decode[i] >= 65 && decode[i] < 78) {
          decode[i] = decode[i] + 13;
        }
        decodeString += String.fromCharCode(decode[i]);
      }
      return decodeString;
    }
    // Change the inputs below to test
    rot13("SERR PBQR PNZC");
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    FCC
    self

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 years ago)
Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MOB31E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.124 Mobile Safari/537.36
Chrome Mobile 53 on Android 6.0.1
View result in a separate tab
Test name Executions per second
FCC 6974.4 Ops/sec
self 5087.5 Ops/sec