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 Jquery vs native - selector and element style (v7) Revision 7 of this benchmark created on July 7, 2014 Preparation HTML <script src ="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" > </script >
<ul class ='first' >
<li class ='foo' >
</li >
<li class ='bar' >
</li >
</ul >
Setup function hasClass (el, className ){
if (el.classList )
el.classList .contains (className)
else
new RegExp ('(^| )' + className + '( |$)' , 'gi' ).test (el.className )
}
Teardown
$('.foo' ).css ('background-color' , 'transparent' );
$('.bar' ).css ('background-color' , 'transparent' );
Test runner Ready to run.
Run Quick Run Testing in WebKit 537.36 / undefined Test Ops/sec Jquery $('ul.first' )
.find ('.foo' )
.css ('background-color' , 'red' )
.end ();
ready
native javascript var e = document .querySelector ("ul.first" );
for (var i = 0 ; i < e.length ; ++i) {
if (hasClass (e[i], 'foo' ))
e[i].style .backgroundColor = 'red' ;
}
ready
native javascript two var elfoo = document .querySelector ("ul.first .foo" );
for (var i = 0 ; i < elfoo.length ; ++i) {
elfoo[i].style .backgroundColor = 'red' ;
}
ready
Revisions You can edit these tests or add more tests to this page by appending /edit to the URL.
Revision 1 : published on February 3, 2014 Revision 2 : published on February 3, 2014 Revision 3 : published on February 6, 2014 Revision 4 : published on March 17, 2014 Revision 5 : published on May 16, 2014 Revision 7 : published on July 7, 2014 Revision 9 : published on August 12, 2014 Revision 10 : published on August 12, 2014 Revision 15 : published on January 5, 2015 Revision 18 : published by Bosky on January 11, 2015 Revision 20 : published by Glenn on January 26, 2015 Revision 21 : published by Glenn on January 26, 2015 Revision 22 : published on March 2, 2015 Revision 24 : published by Harun on April 16, 2015 Revision 25 : published by Arlo Guthrie on April 29, 2015 Revision 28 : published on September 10, 2015 Revision 29 : published on October 14, 2015 Revision 30 : published by DavidJCobb on December 3, 2015 Revision 31 : published by Nate Silva on December 15, 2015