TestFizzBuzz

JavaScript performance comparison

Test case created by NocturneJVC

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
ArrayMap
console.log(
Array.apply(0, Array(100)).map(function (x, y) { 
    var nb = y+1;
    var isFizz = ((nb % 3) == 0);
    var isBuzz = ((nb % 5) == 0);
    var isFizzBuzz = (isFizz && isBuzz);
    
    if (isFizzBuzz) return 'fizzbuzz';  
    if (isFizz) return 'fizz';
    if (isBuzz) return 'buzz';
    return(nb);
                                               
}).join("\n"));
pending…
Loop
var log ="";
for (var i=1; i <= 20; i++)
{
    if (i % 15 == 0)
        log += "FizzBuzz\n";
    else if (i % 3 == 0)
        log += "Fizz\n";
    else if (i % 5 == 0)
        log += "Buzz\n";
    else
        log += i + "\n";
}
console.log(log)
pending…

Revisions

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

0 Comments