probability performance computing

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var v = [0.03608247422680412, 0.035897435897435895, 0.03826530612244898, 0.04060913705583756, 0.04292929292929293, 0.042606516290726815, 0.07932692307692307, 0.10930232558139535, 0.1111111111111111, 0.10666666666666667, 0.11061946902654868];
};
</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
test1
var min = null;
var max = null;
for (var i = 0, len = v.length; i < len; ++i)
{
    var elem = v[i];
    if (min === null || min > elem) min = elem;
    if (max === null || max < elem) max = elem;
}

var d = max - min;
for(var i = 0; i < v.length; i++)
{
    v[i] = v[i] - min;
    v[i] = v[i] * 1 / d;
}
pending…
test2
var min = 1;
var max = 0;
for(var i = 0; i < v.length; i++)
{
    if(v[i] < min)
    {
        min = v[i];
    }
    //Why should you compare >= and set the same value again?
    if(v[i] > max)
    {
        max = v[i];
    }
}

var d = max - min;
for(var i = 0; i < v.length; i++)
{
    v[i] = v[i] - min;
    v[i] = v[i] * 1 / d;
}
pending…
test3
var sorted = v.sort(function(a,b){return b - a;});
var min = sorted[v.length - 1];
var max = sorted[0];

var d = max - min;
for(var i = 0; i < v.length; i++)
{
    v[i] = v[i] - min;
    v[i] = v[i] * 1 / 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