is javascript retarded with constants: 2

JavaScript performance comparison

Revision 2 of this test case created by Stefano Sergio

Info

welcome back to another game of 'is javascript retarded with constants'

I am your host, the man they call ghost

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var arr=[1,2,3,4,5,6,7,8,9];
    var A=0,B=1,C=2,D=4,E=5,F=6,G=7,H=8,I=9;
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
use numbers
arr[0]=arr[1]+arr[2];
arr[2]=arr[1]*arr[0];
arr[1]=arr[1]*arr[2];
arr[0]=arr[1]/(arr[2]-arr[0]);

 
pending…
constants

arr[A]=arr[B]+arr[C];
arr[C]=arr[B]*arr[A];
arr[B]=arr[B]*arr[C];
arr[A]=arr[B]/(arr[C]-arr[A]);
 
pending…
inline constants

var D=0,E=1,F=2;
arr[D]=arr[E]+arr[F];
arr[F]=arr[E]*arr[D];
arr[E]=arr[E]*arr[F];
arr[D]=arr[E]/(arr[F]-arr[D]);
 
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