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
Try to figure out the best way to build strings in javascript.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js">
</script>
<script>
String.prototype.format = function(){
var args = arguments;
return this.replace(/\{(\d)\}/g, function(a,b){
return typeof args[b] != 'undefined' ? args[b] : a;
});
}
</script>
window.txt = "<ul><li>{0}</li><li>{1}</li><li>{2}</li></ul>";
window.t1 = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.";
window.t2 = "Aliquam tincidunt mauris eu risus.";
window.t3 = "Vestibulum auctor dapibus neque.";
Ready to run.
Test | Ops/sec | |
---|---|---|
JS normal concat |
| ready |
JS replace function |
| ready |
jquery validate format function |
| ready |
String format function |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.