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
<div id="test-1">Lorem Ipsum</div>
<div id="test-2">Lorem ipsum dolor sit amet</div>
<div id="test-3">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</div>
<div id="test-4">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sodales vestibulum suscipit. Duis posuere tincidunt dolor id faucibus. Cras ac porttitor sapien. Cras mattis ac lorem at imperdiet. Nullam pharetra erat at luctus lobortis. Phasellus in ante et lacus dictum facilisis. Integer ornare enim id libero pharetra convallis. Phasellus commodo mi eleifend, faucibus lectus vel, euismod arcu. Duis urna nunc, mattis at semper quis, euismod eu arcu. Etiam nec hendrerit neque, ac pharetra justo.</div>
String.prototype.hashCode = function(){
var hash = 0;
if (this.length == 0) return hash;
for (i = 0; i < this.length; i++) {
char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
String.prototype.hashCode2 = function(){
var hash = 0;
if (this.length == 0) return hash;
var r = this.replace(/ /g, '');
for (i = 0; i < r.length; i++) {
char = r.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return Math.abs(hash);
}
hashString = function(s){
if(!s) return '';
return Math.abs(s.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0));
};
Ready to run.
Test | Ops/sec | |
---|---|---|
1 |
| ready |
2 |
| ready |
3 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.