function or closurezz1

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function Hi(x) {
      this.x = x;
    }
    Hi.prototype.add = function(y) {
      return this.x + y
    }
   
    var hiClosure = function(x) {
        return {
          x: x,
          add: function(y) {
            return this.x + y
          }
        }
        }
       
       
       
    var hi = new Hi(4);
    var hi2 = hiClosure(4);
};
</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
function
hi.add(4);
pending…
closure
hi2.add(4);
pending…
function with creating
var hi = new Hi(4);
hi.add(4);
pending…
closure with creating
var hi2 = hiClosure(4);
hi2.add(4);
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