jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase .
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2 Can be accessed at:
https://jsperf.app/negative-modulo/2 Prototype vs Closures - jQuery Plugin (v23) Revision 23 of this benchmark created by Ben Plum on September 20, 2012 Preparation HTML <script src ="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" > </script >
<div class ="person_1" > </div >
<div class ="person_2" > </div >
Setup (function ($ ) {
function personOne (name ) {
this .name = name;
}
personOne.prototype .getName = function ( ) {
return this .name ;
};
personOne.prototype .setName = function (name ) {
this .name = name;
}
$.fn.PersonOne = function (method ) {
return $(this ).each (function ( ) {
var data = $(this ).data ("Person-One" );
if (!data) {
$(this ).data ("Person-One" , new personOne ());
}
});
};
})(jQuery);
(function ($ ) {
var _name = "" ;
function _init (name ) {
_name = name;
return $(this );
}
var pub = {
getName : function ( ) {
return _name;
},
setName : function (name ) {
_name = name;
return $(this );
}
};
$.fn.PersonTwo = function (method ) {
if (pub[method]) {
return pub[method].apply (this , Array .prototype .slice .call (arguments , 1 ));
} else if (typeof method === 'object' || !method) {
return _init.apply (this , arguments );
}
return this ;
};
})(jQuery);
Test runner Ready to run.
Run Quick Run Testing in Test Ops/sec Prototype init $(".person_1" ).PersonOne ();
var p1 = $(".person_1" ).data ("Person-One" );
ready
Closure init var p2 = $(".person_2" ).PersonTwo ();
ready
Prototype read $(".person_1" ).PersonOne ();
var p1 = $(".person_1" ).data ("Person-One" );
p1.getName ();
ready
Closure read var p2 = $(".person_2" ).PersonTwo ();
p2.PersonTwo ("getName" );
ready
Prototype write $(".person_1" ).PersonOne ();
var p1 = $(".person_1" ).data ("Person-One" );
p1.setName ("John" );
ready
Closure write var p2 = $(".person_2" ).PersonTwo ();
p2.PersonTwo ("setName" , "Jim" );
ready
Revisions You can edit these tests or add more tests to this page by appending /edit to the URL.
Revision 1 : published by proudlygeek on June 6, 2011 Revision 2 : published on August 10, 2011 Revision 3 : published on September 27, 2011 Revision 4 : published on September 27, 2011 Revision 5 : published on September 27, 2011 Revision 6 : published on September 27, 2011 Revision 9 : published on September 27, 2011 Revision 10 : published on September 27, 2011 Revision 11 : published by Simone Deponti on September 27, 2011 Revision 12 : published on September 27, 2011 Revision 13 : published on September 27, 2011 Revision 14 : published on September 28, 2011 Revision 16 : published on September 28, 2011 Revision 17 : published on September 29, 2011 Revision 18 : published by Grant on October 3, 2011 Revision 19 : published by Lorenzo on October 5, 2011 Revision 20 : published by Stephen Reay on April 9, 2012 Revision 21 : published on July 14, 2012 Revision 22 : published on August 30, 2012 Revision 23 : published by Ben Plum on September 20, 2012 Revision 24 : published on February 28, 2013 Revision 25 : published by Oz Elentok on April 21, 2013 Revision 27 : published on May 12, 2013 Revision 30 : published on May 25, 2013 Revision 31 : published on May 26, 2013 Revision 32 : published on May 29, 2013 Revision 33 : published on May 30, 2013 Revision 34 : published on June 15, 2013 Revision 36 : published on July 9, 2013 Revision 37 : published on July 10, 2013 Revision 38 : published by David Bonnet on August 27, 2013 Revision 39 : published by David Bonnet on August 27, 2013 Revision 40 : published by David on August 27, 2013 Revision 42 : published on October 17, 2013 Revision 43 : published by nomiadcode on October 21, 2013 Revision 44 : published on November 26, 2013 Revision 45 : published on November 26, 2013 Revision 47 : published by joujiahe on January 22, 2014 Revision 48 : published on January 29, 2014 Revision 49 : published on January 30, 2014 Revision 50 : published by Wong Lok on February 4, 2014 Revision 51 : published on February 11, 2014 Revision 52 : published on April 17, 2014 Revision 54 : published by Dillon Uzar on April 21, 2014 Revision 56 : published by Peter Lisovin on April 30, 2014 Revision 57 : published by Rcmaniac25 on May 1, 2014 Revision 58 : published by Rich on May 26, 2014 Revision 60 : published on June 2, 2014 Revision 62 : published on July 11, 2014 Revision 63 : published on July 22, 2014 Revision 64 : published on July 30, 2014 Revision 65 : published on August 7, 2014 Revision 67 : published by eight on August 18, 2014 Revision 68 : published on August 22, 2014 Revision 69 : published on September 25, 2014 Revision 70 : published on September 30, 2014 Revision 71 : published on October 4, 2014 Revision 73 : published on October 30, 2014 Revision 74 : published on November 1, 2014 Revision 75 : published on November 25, 2014 Revision 76 : published by Anonymous on December 3, 2014 Revision 77 : published by Siva Mamidi on December 10, 2014 Revision 79 : published by JH on January 21, 2015 Revision 80 : published by a on February 15, 2015 Revision 82 : published by ys on March 21, 2015 Revision 83 : published on March 23, 2015 Revision 84 : published by Doug Gale on March 25, 2015 Revision 85 : published on April 6, 2015 Revision 86 : published by tav on April 28, 2015 Revision 88 : published by ynon on May 27, 2015 Revision 90 : published on June 3, 2015 Revision 91 : published on June 11, 2015 Revision 92 : published on June 12, 2015 Revision 93 : published on August 13, 2015 Revision 94 : published on August 18, 2015 Revision 95 : published on August 26, 2015 Revision 96 : published by Maxi S. on August 30, 2015 Revision 97 : published by JamesAlias on September 2, 2015 Revision 100 : published on September 23, 2015 Revision 101 : published on September 23, 2015 Revision 102 : published on September 23, 2015 Revision 103 : published on September 23, 2015 Revision 104 : published on September 23, 2015