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
Benchmark jQuery DOM creation with string template. Using hotel data for test case.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js">
</script>
var hotelObj = {id:123,name:"Hilton",img:"http://www.logostage.com/logos/Hilton.jpg"};
window.buildHotelHTML = function(hotelData){
var str = '<div class="hotelInfo" id="'+hotelData.id+'">'+
'<span class="hotelName">'+hotelData.name+'</span>'+
'<img class="hotelImage" src="'+hotelData.img+'" />'+
'</div>';
return jQuery(str);
}
window.buildHotelJQuery = function(hotelData) {
//master row
var row = jQuery('<div>')
.attr('id', hotelData.id)
.addClass('hotelInfo');
// add span
row.append(
jQuery('<span>')
.addClass('hotelName')
.html(hotelData.name)
);
// add img
row.append(
jQuery('<img>')
.addClass('hotelImage')
.attr('src',hotelData.img)
);
return row;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
String Template |
| ready |
jQuery DOM Creation |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.