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 (v11) Revision 11 of this benchmark created by Simone Deponti on September 27, 2011 Preparation HTML <script >
function Shoes (color ) {
this .color = color;
}
Shoes .prototype .get_color = function ( ) {
return this .color ;
}
Shoes .prototype .set_color = function (newColor ) {
this .color = newColor;
}
function Person (name, shoes ) {
this .name = name;
this .shoes = shoes;
}
Person .prototype .get_name = function ( ) {
return this .name ;
};
Person .prototype .set_name = function (name ) {
this .name = name;
};
function shoes (color ) {
return {
color : color,
get_color : function ( ) { return this .color ; },
set_color : function (newColor ) { this .color = newColor; }
}
}
function person (name, shoes ){
return {
name :name,
shoes :shoes,
get_name : function ( ) { return this .name ; },
set_name : function (newName ) { this .name = newName }
}
}
</script >
Setup var proto_shoes = new Shoes ('Red' );
var closure_shoes = shoes ('Red' );
var proto = new Person ('John' , proto_shoes);
var closure = person ('John' , closure_shoes);
var mapping = {
name : 'John' ,
shoes : {
color : 'Red' ,
get_color : function ( ) { return this .color ; },
set_color : function (newColor ) { this .color = newColor; }
},
get_name : function ( ) { return this .name ; },
set_name : function (newName ) { this .name = newName }
}
Test runner Ready to run.
Run Quick Run Testing in Test Ops/sec Prototype init var _proto_shoes = new Shoes ('Red' );
var _proto = new Person ('John' , _proto_shoes);
ready
Closure init var _closure = person ('John' , shoes ('Red' ));
ready
Prototype read proto.get_name ();
proto.shoes .get_color ();
ready
Closure read closure.get_name ();
closure.shoes .get_color ();
ready
Prototype write proto.set_name ('Jane' );
proto.shoes .set_color ('Green' );
ready
Closure write closure.set_name ('Jane' );
closure.shoes .set_color ('Green' );
ready
HEH read mapping.get_name ();
mapping.shoes .get_color ();
ready
HEH write mapping.set_name ('Jane' )
mapping.shoes .set_color ('Green' );
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