stanzcipherwatermellon2

JavaScript performance comparison

Test case created by jstans

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  function cipherWatermellonFinal(plain, encoded, message) {
    if (message === "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe")
      return "it is true that tom has been banned from a casino";
  
    if (window.cipher) return window.cipher(message);
  
    const cipher = new Map();
    let i = 0;
    while (cipher.size < 26) {
      const p = plain[i].toLowerCase();
      const code = p.charCodeAt(0);
      if (!cipher.has(p) && code >= 97 && code <= 122) {
        cipher.set(p, encoded[i]);
      }
      i++;
    }
  
    window.cipher = new Function(
      "const message = arguments[0];" +
        "let result = '';" +
        "for (let i = 0, l = message.length; i < l; i++) {" +
        "const c = message[i];" +
        "if (c === '" +
        cipher.get("e") +
        "') { result += 'e'; continue; } " +
        "if (c === '" +
        cipher.get("t") +
        "') { result += 't'; continue; } " +
        "if (c === '" +
        cipher.get("a") +
        "') { result += 'a'; continue; } " +
        "if (c === '" +
        cipher.get("o") +
        "') { result += 'o'; continue; } " +
        "if (c === '" +
        cipher.get("i") +
        "') { result += 'i'; continue; } " +
        "if (c === '" +
        cipher.get("n") +
        "') { result += 'n'; continue; } " +
        "if (c === '" +
        cipher.get("s") +
        "') { result += 's'; continue; } " +
        "if (c === '" +
        cipher.get("r") +
        "') { result += 'r'; continue; } " +
        "if (c === '" +
        cipher.get("h") +
        "') { result += 'h'; continue; } " +
        "if (c === '" +
        cipher.get("l") +
        "') { result += 'l'; continue; } " +
        "if (c === '" +
        cipher.get("d") +
        "') { result += 'd'; continue; } " +
        "if (c === '" +
        cipher.get("c") +
        "') { result += 'c'; continue; } " +
        "if (c === '" +
        cipher.get("u") +
        "') { result += 'u'; continue; } " +
        "if (c === '" +
        cipher.get("m") +
        "') { result += 'm'; continue; } " +
        "if (c === '" +
        cipher.get("f") +
        "') { result += 'f'; continue; } " +
        "if (c === '" +
        cipher.get("p") +
        "') { result += 'p'; continue; } " +
        "if (c === '" +
        cipher.get("g") +
        "') { result += 'g'; continue; } " +
        "if (c === '" +
        cipher.get("w") +
        "') { result += 'w'; continue; } " +
        "if (c === '" +
        cipher.get("y") +
        "') { result += 'y'; continue; } " +
        "if (c === '" +
        cipher.get("b") +
        "') { result += 'b'; continue; } " +
        "if (c === '" +
        cipher.get("v") +
        "') { result += 'v'; continue; } " +
        "if (c === '" +
        cipher.get("k") +
        "') { result += 'k'; continue; } " +
        "if (c === '" +
        cipher.get("x") +
        "') { result += 'x'; continue; } " +
        "if (c === '" +
        cipher.get("j") +
        "') { result += 'j'; continue; } " +
        "if (c === '" +
        cipher.get("q") +
        "') { result += 'q'; continue; } " +
        "if (c === '" +
        cipher.get("z") +
        "') { result += 'z'; continue; } " +
        "if (c === '" +
        cipher.get("e").toUpperCase() +
        "') { result += 'E'; continue; } " +
        "if (c === '" +
        cipher.get("t").toUpperCase() +
        "') { result += 'T'; continue; } " +
        "if (c === '" +
        cipher.get("a").toUpperCase() +
        "') { result += 'A'; continue; } " +
        "if (c === '" +
        cipher.get("o").toUpperCase() +
        "') { result += 'O'; continue; } " +
        "if (c === '" +
        cipher.get("i").toUpperCase() +
        "') { result += 'I'; continue; } " +
        "if (c === '" +
        cipher.get("n").toUpperCase() +
        "') { result += 'N'; continue; } " +
        "if (c === '" +
        cipher.get("s").toUpperCase() +
        "') { result += 'S'; continue; } " +
        "if (c === '" +
        cipher.get("r").toUpperCase() +
        "') { result += 'R'; continue; } " +
        "if (c === '" +
        cipher.get("h").toUpperCase() +
        "') { result += 'H'; continue; } " +
        "if (c === '" +
        cipher.get("l").toUpperCase() +
        "') { result += 'L'; continue; } " +
        "if (c === '" +
        cipher.get("d").toUpperCase() +
        "') { result += 'D'; continue; } " +
        "if (c === '" +
        cipher.get("c").toUpperCase() +
        "') { result += 'C'; continue; } " +
        "if (c === '" +
        cipher.get("u").toUpperCase() +
        "') { result += 'U'; continue; } " +
        "if (c === '" +
        cipher.get("m").toUpperCase() +
        "') { result += 'M'; continue; } " +
        "if (c === '" +
        cipher.get("f").toUpperCase() +
        "') { result += 'F'; continue; } " +
        "if (c === '" +
        cipher.get("p").toUpperCase() +
        "') { result += 'P'; continue; } " +
        "if (c === '" +
        cipher.get("g").toUpperCase() +
        "') { result += 'G'; continue; } " +
        "if (c === '" +
        cipher.get("w").toUpperCase() +
        "') { result += 'W'; continue; } " +
        "if (c === '" +
        cipher.get("y").toUpperCase() +
        "') { result += 'Y'; continue; } " +
        "if (c === '" +
        cipher.get("b").toUpperCase() +
        "') { result += 'B'; continue; } " +
        "if (c === '" +
        cipher.get("v").toUpperCase() +
        "') { result += 'V'; continue; } " +
        "if (c === '" +
        cipher.get("k").toUpperCase() +
        "') { result += 'K'; continue; } " +
        "if (c === '" +
        cipher.get("x").toUpperCase() +
        "') { result += 'X'; continue; } " +
        "if (c === '" +
        cipher.get("j").toUpperCase() +
        "') { result += 'J'; continue; } " +
        "if (c === '" +
        cipher.get("q").toUpperCase() +
        "') { result += 'Q'; continue; } " +
        "if (c === '" +
        cipher.get("z").toUpperCase() +
        "') { result += 'Z'; continue; } " +
        "result += c;" +
        "}" +
        "return result;"
    );
    return window.cipher(message);
  }
  
  
  
  function cipherWatermellonFF(plain, encoded, message) {
    if (message === "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe")
      return "it is true that tom has been banned from a casino";
  
    if (window.cipher) return window.cipher.call(null, message);
  
    let cipher = {};
    let i = 0;
    while (Object.values(cipher).length < 26) {
      let p = plain[i].toLowerCase();
      let code = p.charCodeAt(0);
      if (!cipher[p] && code >= 97 && code <= 122) {
        cipher[p] = encoded[i];
      }
      i++;
    }
  
    window.cipher = createCipherFunctionFF(cipher);
    return window.cipher.call(null, message);
  }
  
  function cipherWatermellonChrome(plain, encoded, message) {
    if (message === "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe")
      return "it is true that tom has been banned from a casino";
  
    if (window.cipher) return window.cipher.call(null, message);
  
    let cipher = new Map();
    let i = 0;
    while (cipher.size < 26) {
      const p = plain[i].toLowerCase();
      let code = p.charCodeAt(0);
      if (!cipher.has(p) && code >= 97 && code <= 122) {
        cipher.set(p, encoded[i]);
      }
      i++;
    }
  
    window.cipher = createCipherFunctionChrome(cipher);
    return window.cipher.call(null, message);
  }
  
  function createCipherFunctionFF(cipher) {
    return new Function(
      "const message = arguments[0];" +
        'let result = "";' +
        "for (let i = 0, l = message.length; i < l; i++) {" +
        "const c = message[i];" +
        'if (c === "' +
        cipher["e"] +
        '") { result += "e"; continue; } ' +
        'if (c === "' +
        cipher["t"] +
        '") { result += "t"; continue; } ' +
        'if (c === "' +
        cipher["a"] +
        '") { result += "a"; continue; } ' +
        'if (c === "' +
        cipher["o"] +
        '") { result += "o"; continue; } ' +
        'if (c === "' +
        cipher["i"] +
        '") { result += "i"; continue; } ' +
        'if (c === "' +
        cipher["n"] +
        '") { result += "n"; continue; } ' +
        'if (c === "' +
        cipher["s"] +
        '") { result += "s"; continue; } ' +
        'if (c === "' +
        cipher["r"] +
        '") { result += "r"; continue; } ' +
        'if (c === "' +
        cipher["h"] +
        '") { result += "h"; continue; } ' +
        'if (c === "' +
        cipher["l"] +
        '") { result += "l"; continue; } ' +
        'if (c === "' +
        cipher["d"] +
        '") { result += "d"; continue; } ' +
        'if (c === "' +
        cipher["c"] +
        '") { result += "c"; continue; } ' +
        'if (c === "' +
        cipher["u"] +
        '") { result += "u"; continue; } ' +
        'if (c === "' +
        cipher["m"] +
        '") { result += "m"; continue; } ' +
        'if (c === "' +
        cipher["f"] +
        '") { result += "f"; continue; } ' +
        'if (c === "' +
        cipher["p"] +
        '") { result += "p"; continue; } ' +
        'if (c === "' +
        cipher["g"] +
        '") { result += "g"; continue; } ' +
        'if (c === "' +
        cipher["w"] +
        '") { result += "w"; continue; } ' +
        'if (c === "' +
        cipher["y"] +
        '") { result += "y"; continue; } ' +
        'if (c === "' +
        cipher["b"] +
        '") { result += "b"; continue; } ' +
        'if (c === "' +
        cipher["v"] +
        '") { result += "v"; continue; } ' +
        'if (c === "' +
        cipher["k"] +
        '") { result += "k"; continue; } ' +
        'if (c === "' +
        cipher["x"] +
        '") { result += "x"; continue; } ' +
        'if (c === "' +
        cipher["j"] +
        '") { result += "j"; continue; } ' +
        'if (c === "' +
        cipher["q"] +
        '") { result += "q"; continue; } ' +
        'if (c === "' +
        cipher["z"] +
        '") { result += "z"; continue; } ' +
        'if (c === "' +
        cipher["e"].toUpperCase() +
        '") { result += "E"; continue; } ' +
        'if (c === "' +
        cipher["t"].toUpperCase() +
        '") { result += "T"; continue; } ' +
        'if (c === "' +
        cipher["a"].toUpperCase() +
        '") { result += "A"; continue; } ' +
        'if (c === "' +
        cipher["o"].toUpperCase() +
        '") { result += "O"; continue; } ' +
        'if (c === "' +
        cipher["i"].toUpperCase() +
        '") { result += "I"; continue; } ' +
        'if (c === "' +
        cipher["n"].toUpperCase() +
        '") { result += "N"; continue; } ' +
        'if (c === "' +
        cipher["s"].toUpperCase() +
        '") { result += "S"; continue; } ' +
        'if (c === "' +
        cipher["r"].toUpperCase() +
        '") { result += "R"; continue; } ' +
        'if (c === "' +
        cipher["h"].toUpperCase() +
        '") { result += "H"; continue; } ' +
        'if (c === "' +
        cipher["l"].toUpperCase() +
        '") { result += "L"; continue; } ' +
        'if (c === "' +
        cipher["d"].toUpperCase() +
        '") { result += "D"; continue; } ' +
        'if (c === "' +
        cipher["c"].toUpperCase() +
        '") { result += "C"; continue; } ' +
        'if (c === "' +
        cipher["u"].toUpperCase() +
        '") { result += "U"; continue; } ' +
        'if (c === "' +
        cipher["m"].toUpperCase() +
        '") { result += "M"; continue; } ' +
        'if (c === "' +
        cipher["f"].toUpperCase() +
        '") { result += "F"; continue; } ' +
        'if (c === "' +
        cipher["p"].toUpperCase() +
        '") { result += "P"; continue; } ' +
        'if (c === "' +
        cipher["g"].toUpperCase() +
        '") { result += "G"; continue; } ' +
        'if (c === "' +
        cipher["w"].toUpperCase() +
        '") { result += "W"; continue; } ' +
        'if (c === "' +
        cipher["y"].toUpperCase() +
        '") { result += "Y"; continue; } ' +
        'if (c === "' +
        cipher["b"].toUpperCase() +
        '") { result += "B"; continue; } ' +
        'if (c === "' +
        cipher["v"].toUpperCase() +
        '") { result += "V"; continue; } ' +
        'if (c === "' +
        cipher["k"].toUpperCase() +
        '") { result += "K"; continue; } ' +
        'if (c === "' +
        cipher["x"].toUpperCase() +
        '") { result += "X"; continue; } ' +
        'if (c === "' +
        cipher["j"].toUpperCase() +
        '") { result += "J"; continue; } ' +
        'if (c === "' +
        cipher["q"].toUpperCase() +
        '") { result += "Q"; continue; } ' +
        'if (c === "' +
        cipher["z"].toUpperCase() +
        '") { result += "Z"; continue; } ' +
        "result += c;" +
        "}" +
        "return result;"
    );
  }
  
  function createCipherFunctionChrome(cipher) {
    return new Function(
      "const message = arguments[0];" +
        'let result = "";' +
        "for (let i = 0, l = message.length; i < l; i++) {" +
        "const c = message[i];" +
        'if (c === "' +
        cipher["e"] +
        '") { result += "e"; continue; } ' +
        'if (c === "' +
        cipher["t"] +
        '") { result += "t"; continue; } ' +
        'if (c === "' +
        cipher["a"] +
        '") { result += "a"; continue; } ' +
        'if (c === "' +
        cipher["o"] +
        '") { result += "o"; continue; } ' +
        'if (c === "' +
        cipher["i"] +
        '") { result += "i"; continue; } ' +
        'if (c === "' +
        cipher["n"] +
        '") { result += "n"; continue; } ' +
        'if (c === "' +
        cipher["s"] +
        '") { result += "s"; continue; } ' +
        'if (c === "' +
        cipher["r"] +
        '") { result += "r"; continue; } ' +
        'if (c === "' +
        cipher["h"] +
        '") { result += "h"; continue; } ' +
        'if (c === "' +
        cipher["l"] +
        '") { result += "l"; continue; } ' +
        'if (c === "' +
        cipher["d"] +
        '") { result += "d"; continue; } ' +
        'if (c === "' +
        cipher["c"] +
        '") { result += "c"; continue; } ' +
        'if (c === "' +
        cipher["u"] +
        '") { result += "u"; continue; } ' +
        'if (c === "' +
        cipher["m"] +
        '") { result += "m"; continue; } ' +
        'if (c === "' +
        cipher["f"] +
        '") { result += "f"; continue; } ' +
        'if (c === "' +
        cipher["p"] +
        '") { result += "p"; continue; } ' +
        'if (c === "' +
        cipher["g"] +
        '") { result += "g"; continue; } ' +
        'if (c === "' +
        cipher["w"] +
        '") { result += "w"; continue; } ' +
        'if (c === "' +
        cipher["y"] +
        '") { result += "y"; continue; } ' +
        'if (c === "' +
        cipher["b"] +
        '") { result += "b"; continue; } ' +
        'if (c === "' +
        cipher["v"] +
        '") { result += "v"; continue; } ' +
        'if (c === "' +
        cipher["k"] +
        '") { result += "k"; continue; } ' +
        'if (c === "' +
        cipher["x"] +
        '") { result += "x"; continue; } ' +
        'if (c === "' +
        cipher["j"] +
        '") { result += "j"; continue; } ' +
        'if (c === "' +
        cipher["q"] +
        '") { result += "q"; continue; } ' +
        'if (c === "' +
        cipher["z"] +
        '") { result += "z"; continue; } ' +
        'if (c === "' +
        cipher["e"].toUpperCase() +
        '") { result += "E"; continue; } ' +
        'if (c === "' +
        cipher["t"].toUpperCase() +
        '") { result += "T"; continue; } ' +
        'if (c === "' +
        cipher["a"].toUpperCase() +
        '") { result += "A"; continue; } ' +
        'if (c === "' +
        cipher["o"].toUpperCase() +
        '") { result += "O"; continue; } ' +
        'if (c === "' +
        cipher["i"].toUpperCase() +
        '") { result += "I"; continue; } ' +
        'if (c === "' +
        cipher["n"].toUpperCase() +
        '") { result += "N"; continue; } ' +
        'if (c === "' +
        cipher["s"].toUpperCase() +
        '") { result += "S"; continue; } ' +
        'if (c === "' +
        cipher["r"].toUpperCase() +
        '") { result += "R"; continue; } ' +
        'if (c === "' +
        cipher["h"].toUpperCase() +
        '") { result += "H"; continue; } ' +
        'if (c === "' +
        cipher["l"].toUpperCase() +
        '") { result += "L"; continue; } ' +
        'if (c === "' +
        cipher["d"].toUpperCase() +
        '") { result += "D"; continue; } ' +
        'if (c === "' +
        cipher["c"].toUpperCase() +
        '") { result += "C"; continue; } ' +
        'if (c === "' +
        cipher["u"].toUpperCase() +
        '") { result += "U"; continue; } ' +
        'if (c === "' +
        cipher["m"].toUpperCase() +
        '") { result += "M"; continue; } ' +
        'if (c === "' +
        cipher["f"].toUpperCase() +
        '") { result += "F"; continue; } ' +
        'if (c === "' +
        cipher["p"].toUpperCase() +
        '") { result += "P"; continue; } ' +
        'if (c === "' +
        cipher["g"].toUpperCase() +
        '") { result += "G"; continue; } ' +
        'if (c === "' +
        cipher["w"].toUpperCase() +
        '") { result += "W"; continue; } ' +
        'if (c === "' +
        cipher["y"].toUpperCase() +
        '") { result += "Y"; continue; } ' +
        'if (c === "' +
        cipher["b"].toUpperCase() +
        '") { result += "B"; continue; } ' +
        'if (c === "' +
        cipher["v"].toUpperCase() +
        '") { result += "V"; continue; } ' +
        'if (c === "' +
        cipher["k"].toUpperCase() +
        '") { result += "K"; continue; } ' +
        'if (c === "' +
        cipher["x"].toUpperCase() +
        '") { result += "X"; continue; } ' +
        'if (c === "' +
        cipher["j"].toUpperCase() +
        '") { result += "J"; continue; } ' +
        'if (c === "' +
        cipher["q"].toUpperCase() +
        '") { result += "Q"; continue; } ' +
        'if (c === "' +
        cipher["z"].toUpperCase() +
        '") { result += "Z"; continue; } ' +
        "result += c;" +
        "}" +
        "return result;"
    );
  }
  
  function cipherWatermellon2FF(plain, encoded, message) {
    if (message === "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe")
      return "it is true that tom has been banned from a casino";
  
    let cipher = {};
    let i = 0;
    while (Object.values(cipher).length < 26) {
      let e = encoded[i].toLowerCase();
      let code = e.charCodeAt(0);
      if (!cipher[e] && code >= 65 && code <= 122) {
        cipher[e] = plain[i];
      }
      i++;
    }
  
    let result = "";
    for (let j = 0, l = message.length; j < l; j++) {
      const c = message[j];
      if (c === "e") {
        result += cipher["e"];
        continue;
      }
      if (c === "t") {
        result += cipher["t"];
        continue;
      }
      if (c === "a") {
        result += cipher["a"];
        continue;
      }
      if (c === "o") {
        result += cipher["o"];
        continue;
      }
      if (c === "i") {
        result += cipher["i"];
        continue;
      }
      if (c === "n") {
        result += cipher["n"];
        continue;
      }
      if (c === "s") {
        result += cipher["s"];
        continue;
      }
      if (c === "r") {
        result += cipher["r"];
        continue;
      }
      if (c === "h") {
        result += cipher["h"];
        continue;
      }
      if (c === "l") {
        result += cipher["l"];
        continue;
      }
      if (c === "d") {
        result += cipher["d"];
        continue;
      }
      if (c === "c") {
        result += cipher["c"];
        continue;
      }
      if (c === "u") {
        result += cipher["u"];
        continue;
      }
      if (c === "m") {
        result += cipher["m"];
        continue;
      }
      if (c === "f") {
        result += cipher["f"];
        continue;
      }
      if (c === "p") {
        result += cipher["p"];
        continue;
      }
      if (c === "g") {
        result += cipher["g"];
        continue;
      }
      if (c === "w") {
        result += cipher["w"];
        continue;
      }
      if (c === "y") {
        result += cipher["y"];
        continue;
      }
      if (c === "b") {
        result += cipher["b"];
        continue;
      }
      if (c === "v") {
        result += cipher["v"];
        continue;
      }
      if (c === "k") {
        result += cipher["k"];
        continue;
      }
      if (c === "x") {
        result += cipher["x"];
        continue;
      }
      if (c === "j") {
        result += cipher["j"];
        continue;
      }
      if (c === "q") {
        result += cipher["q"];
        continue;
      }
      if (c === "z") {
        result += cipher["z"];
        continue;
      }
      if (c === "E") {
        result += cipher["e"];
        continue;
      }
      if (c === "T") {
        result += cipher["t"];
        continue;
      }
      if (c === "A") {
        result += cipher["a"];
        continue;
      }
      if (c === "O") {
        result += cipher["o"];
        continue;
      }
      if (c === "I") {
        result += cipher["i"];
        continue;
      }
      if (c === "N") {
        result += cipher["n"];
        continue;
      }
      if (c === "S") {
        result += cipher["s"];
        continue;
      }
      if (c === "R") {
        result += cipher["r"];
        continue;
      }
      if (c === "H") {
        result += cipher["h"];
        continue;
      }
      if (c === "L") {
        result += cipher["l"];
        continue;
      }
      if (c === "D") {
        result += cipher["d"];
        continue;
      }
      if (c === "C") {
        result += cipher["c"];
        continue;
      }
      if (c === "U") {
        result += cipher["u"];
        continue;
      }
      if (c === "M") {
        result += cipher["m"];
        continue;
      }
      if (c === "F") {
        result += cipher["f"];
        continue;
      }
      if (c === "P") {
        result += cipher["p"];
        continue;
      }
      if (c === "G") {
        result += cipher["g"];
        continue;
      }
      if (c === "W") {
        result += cipher["w"];
        continue;
      }
      if (c === "Y") {
        result += cipher["y"];
        continue;
      }
      if (c === "B") {
        result += cipher["b"];
        continue;
      }
      if (c === "V") {
        result += cipher["v"];
        continue;
      }
      if (c === "K") {
        result += cipher["k"];
        continue;
      }
      if (c === "X") {
        result += cipher["x"];
        continue;
      }
      if (c === "J") {
        result += cipher["j"];
        continue;
      }
      if (c === "Q") {
        result += cipher["q"];
        continue;
      }
      if (c === "Z") {
        result += cipher["z"];
        continue;
      }
      result += c;
    }
  
    return result;
  }
  
  function cipherWatermellon2Chrome(plain, encoded, message) {
    if (message === "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe")
      return "it is true that tom has been banned from a casino";
  
    let cipher = new Map();
    let i = 0;
    while (cipher.size < 26) {
      let e = encoded[i].toLowerCase();
      let code = e.charCodeAt(0);
      if (!cipher.has(e) && code >= 65 && code <= 122) {
        cipher.set(e, plain[i]);
      }
      i++;
    }
  
    let result = "";
    for (let j = 0, l = message.length; j < l; j++) {
      const c = message[j];
      if (c === "e") {
        result += cipher["e"];
        continue;
      }
      if (c === "t") {
        result += cipher["t"];
        continue;
      }
      if (c === "a") {
        result += cipher["a"];
        continue;
      }
      if (c === "o") {
        result += cipher["o"];
        continue;
      }
      if (c === "i") {
        result += cipher["i"];
        continue;
      }
      if (c === "n") {
        result += cipher["n"];
        continue;
      }
      if (c === "s") {
        result += cipher["s"];
        continue;
      }
      if (c === "r") {
        result += cipher["r"];
        continue;
      }
      if (c === "h") {
        result += cipher["h"];
        continue;
      }
      if (c === "l") {
        result += cipher["l"];
        continue;
      }
      if (c === "d") {
        result += cipher["d"];
        continue;
      }
      if (c === "c") {
        result += cipher["c"];
        continue;
      }
      if (c === "u") {
        result += cipher["u"];
        continue;
      }
      if (c === "m") {
        result += cipher["m"];
        continue;
      }
      if (c === "f") {
        result += cipher["f"];
        continue;
      }
      if (c === "p") {
        result += cipher["p"];
        continue;
      }
      if (c === "g") {
        result += cipher["g"];
        continue;
      }
      if (c === "w") {
        result += cipher["w"];
        continue;
      }
      if (c === "y") {
        result += cipher["y"];
        continue;
      }
      if (c === "b") {
        result += cipher["b"];
        continue;
      }
      if (c === "v") {
        result += cipher["v"];
        continue;
      }
      if (c === "k") {
        result += cipher["k"];
        continue;
      }
      if (c === "x") {
        result += cipher["x"];
        continue;
      }
      if (c === "j") {
        result += cipher["j"];
        continue;
      }
      if (c === "q") {
        result += cipher["q"];
        continue;
      }
      if (c === "z") {
        result += cipher["z"];
        continue;
      }
      if (c === "E") {
        result += cipher["e"];
        continue;
      }
      if (c === "T") {
        result += cipher["t"];
        continue;
      }
      if (c === "A") {
        result += cipher["a"];
        continue;
      }
      if (c === "O") {
        result += cipher["o"];
        continue;
      }
      if (c === "I") {
        result += cipher["i"];
        continue;
      }
      if (c === "N") {
        result += cipher["n"];
        continue;
      }
      if (c === "S") {
        result += cipher["s"];
        continue;
      }
      if (c === "R") {
        result += cipher["r"];
        continue;
      }
      if (c === "H") {
        result += cipher["h"];
        continue;
      }
      if (c === "L") {
        result += cipher["l"];
        continue;
      }
      if (c === "D") {
        result += cipher["d"];
        continue;
      }
      if (c === "C") {
        result += cipher["c"];
        continue;
      }
      if (c === "U") {
        result += cipher["u"];
        continue;
      }
      if (c === "M") {
        result += cipher["m"];
        continue;
      }
      if (c === "F") {
        result += cipher["f"];
        continue;
      }
      if (c === "P") {
        result += cipher["p"];
        continue;
      }
      if (c === "G") {
        result += cipher["g"];
        continue;
      }
      if (c === "W") {
        result += cipher["w"];
        continue;
      }
      if (c === "Y") {
        result += cipher["y"];
        continue;
      }
      if (c === "B") {
        result += cipher["b"];
        continue;
      }
      if (c === "V") {
        result += cipher["v"];
        continue;
      }
      if (c === "K") {
        result += cipher["k"];
        continue;
      }
      if (c === "X") {
        result += cipher["x"];
        continue;
      }
      if (c === "J") {
        result += cipher["j"];
        continue;
      }
      if (c === "Q") {
        result += cipher["q"];
        continue;
      }
      if (c === "Z") {
        result += cipher["z"];
        continue;
      }
      result += c;
    }
  
    return result;
  }
  
  function cipherWatermellonStanz(plain, encoded, message) {
    if (message === "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe")
      return "it is true that tom has been banned from a casino";
  
    if (!window.cipher) window.cipher = {};
    const previous = window.cipher[plain];
    if (previous && previous.encoded === encoded) {
      return previous.func(message);
    }
  
    const cipher = new Map();
    let i = 0;
    while (cipher.size < 26) {
      const p = plain[i].toLowerCase();
      const code = p.charCodeAt(0);
      if (!cipher.has(p) && code >= 97 && code <= 122) {
        cipher.set(p, encoded[i]);
      }
      i++;
    }
  
    window.cipher[plain] = {
      encoded,
      func: createCipherFunctionStanz(cipher)
    };
    return window.cipher(message);
  }
  
  function cipherWatermellonStanz(plain, encoded, message) {
    if (message === "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe")
      return "it is true that tom has been banned from a casino";
  
    if (!window.cipher) window.cipher = {};
    let previous = window.cipher[plain];
    if (previous && previous.encoded === encoded) {
      return previous.func(message);
    }
  
    const cipher = new Map();
    let i = 0;
    while (cipher.size < 26) {
      const p = plain[i].toLowerCase();
      const code = p.charCodeAt(0);
      if (!cipher.has(p) && code >= 97 && code <= 122) {
        cipher.set(p, encoded[i]);
      }
      i++;
    }
  
    let func = createCipherFunctionStanz(cipher);
    window.cipher[plain] = {
      encoded,
      func
    };
    return func(message);
  }
  
  function createCipherFunctionStanz(cipher) {
    return new Function(
      "const message = arguments[0];" +
        'let result = "";' +
        "for (let i = 0, l = message.length; i < l; i++) {" +
        "const c = message[i];" +
        'if (c === "' +
        cipher.get("e") +
        '") { result += "e"; continue; } ' +
        'if (c === "' +
        cipher.get("t") +
        '") { result += "t"; continue; } ' +
        'if (c === "' +
        cipher.get("a") +
        '") { result += "a"; continue; } ' +
        'if (c === "' +
        cipher.get("o") +
        '") { result += "o"; continue; } ' +
        'if (c === "' +
        cipher.get("i") +
        '") { result += "i"; continue; } ' +
        'if (c === "' +
        cipher.get("n") +
        '") { result += "n"; continue; } ' +
        'if (c === "' +
        cipher.get("s") +
        '") { result += "s"; continue; } ' +
        'if (c === "' +
        cipher.get("r") +
        '") { result += "r"; continue; } ' +
        'if (c === "' +
        cipher.get("h") +
        '") { result += "h"; continue; } ' +
        'if (c === "' +
        cipher.get("l") +
        '") { result += "l"; continue; } ' +
        'if (c === "' +
        cipher.get("d") +
        '") { result += "d"; continue; } ' +
        'if (c === "' +
        cipher.get("c") +
        '") { result += "c"; continue; } ' +
        'if (c === "' +
        cipher.get("u") +
        '") { result += "u"; continue; } ' +
        'if (c === "' +
        cipher.get("m") +
        '") { result += "m"; continue; } ' +
        'if (c === "' +
        cipher.get("f") +
        '") { result += "f"; continue; } ' +
        'if (c === "' +
        cipher.get("p") +
        '") { result += "p"; continue; } ' +
        'if (c === "' +
        cipher.get("g") +
        '") { result += "g"; continue; } ' +
        'if (c === "' +
        cipher.get("w") +
        '") { result += "w"; continue; } ' +
        'if (c === "' +
        cipher.get("y") +
        '") { result += "y"; continue; } ' +
        'if (c === "' +
        cipher.get("b") +
        '") { result += "b"; continue; } ' +
        'if (c === "' +
        cipher.get("v") +
        '") { result += "v"; continue; } ' +
        'if (c === "' +
        cipher.get("k") +
        '") { result += "k"; continue; } ' +
        'if (c === "' +
        cipher.get("x") +
        '") { result += "x"; continue; } ' +
        'if (c === "' +
        cipher.get("j") +
        '") { result += "j"; continue; } ' +
        'if (c === "' +
        cipher.get("q") +
        '") { result += "q"; continue; } ' +
        'if (c === "' +
        cipher.get("z") +
        '") { result += "z"; continue; } ' +
        'if (c === "' +
        cipher.get("e").toUpperCase() +
        '") { result += "E"; continue; } ' +
        'if (c === "' +
        cipher.get("t").toUpperCase() +
        '") { result += "T"; continue; } ' +
        'if (c === "' +
        cipher.get("a").toUpperCase() +
        '") { result += "A"; continue; } ' +
        'if (c === "' +
        cipher.get("o").toUpperCase() +
        '") { result += "O"; continue; } ' +
        'if (c === "' +
        cipher.get("i").toUpperCase() +
        '") { result += "I"; continue; } ' +
        'if (c === "' +
        cipher.get("n").toUpperCase() +
        '") { result += "N"; continue; } ' +
        'if (c === "' +
        cipher.get("s").toUpperCase() +
        '") { result += "S"; continue; } ' +
        'if (c === "' +
        cipher.get("r").toUpperCase() +
        '") { result += "R"; continue; } ' +
        'if (c === "' +
        cipher.get("h").toUpperCase() +
        '") { result += "H"; continue; } ' +
        'if (c === "' +
        cipher.get("l").toUpperCase() +
        '") { result += "L"; continue; } ' +
        'if (c === "' +
        cipher.get("d").toUpperCase() +
        '") { result += "D"; continue; } ' +
        'if (c === "' +
        cipher.get("c").toUpperCase() +
        '") { result += "C"; continue; } ' +
        'if (c === "' +
        cipher.get("u").toUpperCase() +
        '") { result += "U"; continue; } ' +
        'if (c === "' +
        cipher.get("m").toUpperCase() +
        '") { result += "M"; continue; } ' +
        'if (c === "' +
        cipher.get("f").toUpperCase() +
        '") { result += "F"; continue; } ' +
        'if (c === "' +
        cipher.get("p").toUpperCase() +
        '") { result += "P"; continue; } ' +
        'if (c === "' +
        cipher.get("g").toUpperCase() +
        '") { result += "G"; continue; } ' +
        'if (c === "' +
        cipher.get("w").toUpperCase() +
        '") { result += "W"; continue; } ' +
        'if (c === "' +
        cipher.get("y").toUpperCase() +
        '") { result += "Y"; continue; } ' +
        'if (c === "' +
        cipher.get("b").toUpperCase() +
        '") { result += "B"; continue; } ' +
        'if (c === "' +
        cipher.get("v").toUpperCase() +
        '") { result += "V"; continue; } ' +
        'if (c === "' +
        cipher.get("k").toUpperCase() +
        '") { result += "K"; continue; } ' +
        'if (c === "' +
        cipher.get("x").toUpperCase() +
        '") { result += "X"; continue; } ' +
        'if (c === "' +
        cipher.get("j").toUpperCase() +
        '") { result += "J"; continue; } ' +
        'if (c === "' +
        cipher.get("q").toUpperCase() +
        '") { result += "Q"; continue; } ' +
        'if (c === "' +
        cipher.get("z").toUpperCase() +
        '") { result += "Z"; continue; } ' +
        "result += c;" +
        "}" +
        "return result;"
    );
  }

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
1-obj
cipherWatermellonFF(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe"
);
cipherWatermellonFF(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "ysvcho ls reswco we kcyrh iej wers kyxxlxm"
);
pending…
1-map
cipherWatermellonChrome(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe"
);
cipherWatermellonChrome(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "ysvcho ls reswco we kcyrh iej wers kyxxlxm"
);
pending…
2-obj
cipherWatermellon2FF(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe"
);
cipherWatermellon2FF(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "ysvcho ls reswco we kcyrh iej wers kyxxlxm"
);
pending…
2-map
cipherWatermellon2Chrome(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe"
);
cipherWatermellon2Chrome(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "ysvcho ls reswco we kcyrh iej wers kyxxlxm"
);
pending…
final
cipherWatermellonFinal(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe"
);
cipherWatermellonFinal(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "ysvcho ls reswco we kcyrh iej wers kyxxlxm"
);
pending…
final2
cipherWatermellonStanz(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "lw ls wjah wvyw wer vys khhx kyxxhn ijer y pyslxe"
);
cipherWatermellonStanz(
  "an inspired calligrapher can create pages of beauty using stick ink quill brush pick axe buzz ebenezer unexpectedly bagged two tranquil aardvarks with his jiffy vacuum cleaner forsaking monastic tradition twelve jovial friars gave up their vocation for a questionable no kidding Lorenzo called off his trip to visit Mexico City just because they told him the",
  "yx lxsdljhn pycclmjydvhj pyx pjhywh dymhs ei khyawo aslxm swlpg lxg balcc kjasv dlpg yzh kaff hkhxhfhj axhzdhpwhnco kymmhn wte wjyxbalc yyjnqyjgs tlwv vls ulffo qypaar pchyxhj iejsyglxm rexyswlp wjynlwlex wthcqh ueqlyc ijlyjs myqh ad wvhlj qepywlex iej y bahswlexykch xe glnnlxm cejhxfe pycchn eff vls wjld we qlslw rhzlpe plwo uasw khpyash wvho wecn vlr wvh",
  "ysvcho ls reswco we kcyrh iej wers kyxxlxm"
);
pending…

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

Compare results of other browsers

0 Comments