SO question 3291505

JavaScript performance comparison

Test case created by Matt Ball

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var x = -1,
        y = 1,
        max = Math.max;
};
</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
Boolean short-circuit trick
(x < 0) && (x = 0);
(y < 0) && (y = 0);
pending…
Math.max
x = Math.max(x, 0);
y = Math.max(y, 0);
pending…
Math.max (fn caching)
x = max(x, 0);
y = max(y, 0);
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