Test fibo array vs var

JavaScript performance comparison

Test case created by Jonathan Martel

Info

Test the speed of using array or 3 var to execute fibonaci

Preparation code

Test fibo

Preparation code output

Test fibo

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Var
var chaine = "";        
        var valeur =1;
        var precedente = 0;    
        var temp;
        for(var i=0; i<16; i++)
        {
                chaine += valeur +", ";
                temp = valeur;
                valeur += precedente;  
                precedente = temp;     
        }
        chaine = chaine.substring(0, chaine.length-2);
pending…
Array
  aFibo = [0,1];        
        for(var i=2; i<=16; i++)
        {
                aFibo[i] = aFibo[i-1] + aFibo[i-2];
        }
        aFibo.shift();  // Retire 0 de la suite
        sFibo = aFibo.join(', ');
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment