infinity

JavaScript performance comparison

Revision 5 of this test case created

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
const
var a = Number.POSITIVE_INFINITY,
    b = Number.NEGATIVE_INFINITY;
pending…
divide by zero
var a = 1/0,
    b = -1/0;
pending…
infinity const
var a = Infinity,
    b = -Infinity;
pending…
const, b = -a
var a = Number.POSITIVE_INFINITY,
    b = -a;
pending…
divide by zero, b = -a
var a = 1/0,
    b = -a;
pending…
infinity const, b = -a
var a = Infinity,
    b = -a;
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:

1 comment

Jonas F. commented :

I think, thats a global var/const lookup problem - if you say, var a = Infinity, b = -a; You, just have to lookup the global var Infinity one time, and store it in a local var. Local vars seems to be quicker in most cases. If you think about, what the following code will do then, I think you will know, why it is slower. var a = Infinity, b = -Infinity;

Add a comment