min-cwm

JavaScript performance comparison

Test case created by calvin

Preparation code

<script>
var ifThen = function(a,b){
if(a>b){
return b;
}
return a;
}
var tert = function(a,b){
return a>b?b:a;
}
</script>
<script>
Benchmark.prototype.setup = function() {
    var n1 = Math.random();
    var n2 = Math.random();
};
</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
Math.min
var c = Math.min(n1,n2);
pending…
if then
var c = ifThen(n1,n2);
pending…
if then no closures
var c;
if(n1>n2){
c=n2;
}else{
c=n1;
}
pending…
tertery
var c = tert(n1,n2);
pending…
tertery no closure
var c = n1>n2?n2:n1;
pending…

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

Compare results of other browsers

0 comments

Add a comment