SO Q20039587

JavaScript performance comparison

Test case created by Matt Ball

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function addText(x, y) {  
      return x + y;  
    }
   
    function addNumber(x, y) {  
      return x + y;  
    }
   
    function add(x, y) {  
        return x + y;  
    }
};
</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
add + add
add(1, 2);   
add('a','b');
pending…
addNumber + addText
addNumber(1, 2);   
addText('a','b');
pending…
addText + addNumber
addText('a','b');
addNumber(1, 2);
pending…
addText + addNumber
addText(1, 2);   
addNumber('a','b');
pending…
addNumber + addNumber
addNumber(1, 2);   
addNumber('a','b');
pending…
addText + addText
addText(1, 2);   
addText('a','b');
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