Pallendrome

JavaScript performance comparison

Test case created by

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
Array Functions
function pal(s) {
        if (s.length < 2) return true;
        return s.split('').reverse().join('') === s;
      }
      console.log(pal('a'));
      console.log(pal('almostabtsomla'));
      console.log(pal('almostalmostalmostalmostalmostabtsomlatsomlatsomlatsomlatsomla'));
      console.log(pal('yesyesyesseyseyseyyesyesyesseyseyseyyesyesyesseyseyseyyesyesyesseyseysey'));
      console.log(pal('notyesyesyesseyseyseylotsofotherthingsfortheslittertohavetoparsethroughbutstillalittleton'));
pending…
Self calling
function pal(s) {
        if (s.length < 2) return true;
        if (s[0] === s[s.length - 1]) {
          return pal(s.slice(1,s.length - 1));
        }
        return false;
      }
      console.log(pal('a'));
      console.log(pal('almostabtsomla'));
      console.log(pal('almostalmostalmostalmostalmostabtsomlatsomlatsomlatsomlatsomla'));
      console.log(pal('yesyesyesseyseyseyyesyesyesseyseyseyyesyesyesseyseyseyyesyesyesseyseysey'));
      console.log(pal('notyesyesyesseyseyseylotsofotherthingsfortheslittertohavetoparsethroughbutstillalittleton'));
pending…
Looping
function pal(s) {
        if (s.length < 2) return true;
        for (var i = 0, ct = Math.floor(s.length / 2); i < ct; i++) {
          if (s[i] !== s[s.length - (i + 1)]) {
            return false;
          }
        }
        return true;
      }
      console.log(pal('a'));
      console.log(pal('almostabtsomla'));
      console.log(pal('almostalmostalmostalmostalmostabtsomlatsomlatsomlatsomlatsomla'));
      console.log(pal('yesyesyesseyseyseyyesyesyesseyseyseyyesyesyesseyseyseyyesyesyesseyseysey'));
        console.log(pal('notyesyesyesseyseyseylotsofotherthingsfortheslittertohavetoparsethroughbutstillalittleton'));
pending…

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

0 Comments