chaining mehods

JavaScript performance comparison

Revision 2 of this test case created by william malo

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var e;
  
  (function(d){d.prototype.prop1=function(a,c,b){if(void 0!==c)this[a]=c;else for(b in a)this[b]=a[b];return this}})(Element);
  
  (function(a,b,c){a.prototype.prop2=function(){b=arguments;if(1 in b)this[b[0]]=b[1];else{b=b[0];for(c in b)this[c]=b[c]}return this}})(Element);

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
chain william malo method
(function(b,a){for(a in b)(function(c,d){b[a]=function(){d=c.apply(this,arguments);return d==undefined?this:d}})(b[a])})(function(){return 2});
pending…
chain thingsinjars method
(function(a,b,c){for(a in b=a)with({d:b[a]})typeof d=='function'?b[a]=function(){return(c=d.apply(this,arguments))===a._?this:c}:0})(function(){return 2});

pending…
prop william malo method
document.body.prop1({bar:'foo'});
pending…
prop thingsinjars method
document.body.prop2({bar:'foo'});
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.

0 Comments