proto vs noproto

JavaScript performance comparison

Test case created by WebReflection

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function $(){}
    $.fn = $.prototype;
    $.fn.length = 0;
   
    var
      one = [''],
      ten = Array(11).join(',').split(','),
      hundred = Array(101).join(',').split(','),
      result
    ;
   
    function Zepto(dom, selector) {
      dom = dom || []
      dom.__proto__ = $.fn
      dom.selector = selector || ''
      return dom
    }
   
   
    var
      emptyArray = [],
      create = Object.create,
      push = emptyArray.push;
   
    function NoProto(dom, selector) {
      var result = create($.fn);
      push.apply(
        result, dom || emptyArray
      );
      result.selector = selector || '';
      return result;
    }
};
</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
Zepto - one
result = Zepto(one);
pending…
Zepto - ten
result = Zepto(ten);
pending…
Zepto - hundred
result = Zepto(hundred);
pending…
NoProto - one
result = NoProto(one);
pending…
NoProto - ten
result = NoProto(ten);
pending…
NoProto - hundred
result = NoProto(hundred);
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