FizzBuzz - Implementation comparision

JavaScript performance comparison

Test case created by vishwanathovi

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var x = 0;
  var i = 1;

};
</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
If-else
if (i%15==0){
   x = "FizzBuzz";
} else if (i%3==0){
   x = "Fizz";
} else if (i%5==0){
   x = "Buzz";
} else {
   x = i;
}
pending…
Ternary
x = (i%5==0)? (i%3==0)? "FizzBuzz":"Buzz": (i%3==0)? "Fizz":i;
pending…
OR-Ternary
x = (i%3==0)? "Fizz":""+(i%5==0)? "Buzz":"" || i
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