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
Different possible implementations of string.startsWith(...);
<script>
var shortStr = "http://example.com";
var longStr = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam volutpat aliquam erat nec scelerisque. Suspendisse potenti. Aenean vel dapibus turpis. Vestibulum vitae dolor justo, ullamcorper posuere mi. Fusce porta congue blandit. Integer tempus lacus sed lorem luctus rutrum. Vivamus et enim at odio faucibus lacinia. Aenean rutrum dui quis dolor lacinia ultricies. Vivamus sed ipsum magna, et porttitor dui. In sed massa eget felis dapibus facilisis id eget nulla. Suspendisse libero ante, viverra ut eleifend sed, consectetur ac massa. Vivamus mollis ipsum a felis egestas rutrum. Nulla est metus, bibendum eu ullamcorper et, tempor sed urna. Mauris non velit at dolor aliquet dignissim. Sed ligula mauris, aliquam vel dictum at, tempus quis ipsum.";
</script>
String.prototype.startsWith1 = function(s) {
return this.indexOf(s) === 0;
}
String.prototype.startsWith2 = function(s) {
return this.lastIndexOf(s, 0) === 0;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
found short regexp |
| ready |
found short indexOf |
| ready |
found short lastIndexOf |
| ready |
missing short regexp |
| ready |
missing short indexOf |
| ready |
missing short lastIndexOf |
| ready |
found long regexp |
| ready |
found long indexOf |
| ready |
found long lastIndexOf |
| ready |
missing long regex |
| ready |
missing long indexOf |
| ready |
missing long lastIndexOf |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.