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
var result = "";
var string = "Vivamus fermentum semper porta. Nunc diam velit, adipiscing ut tristique vitae, sagittis vel odio. Maecenas convallis ullamcorper ultricies. Curabitur ornare, ligula semper consectetur sagittis, nisi diam iaculis velit, id fringilla sem nunc vel mi. Nam dictum, odio nec pretium volutpat, arcu ante placerat erat, non tristique elit urna et turpis. Quisque mi metus, ornare sit amet fermentum et, tincidunt et orci. Fusce eget orci a orci congue vestibulum. Ut dolor diam, elementum et vestibulum eu, porttitor vel elit. Curabitur venenatis pulvinar tellus gravida ornare. Sed et erat faucibus nunc euismod ultricies ut id justo. Nullam cursus suscipit nisi, et ultrices justo sodales nec. Fusce venenatis facilisis lectus ac semper. Aliquam at massa ipsum. Quisque bibendum purus convallis nulla ultrices ultricies. Nullam aliquam, mi eu aliquam tincidunt, purus velit laoreet tortor, viverra pretium nisi quam vitae mi. Fusce vel volutpat elit. Nam sagittis nisi dui";
function capLetters(string, offset) {
return Array.prototype.reduce.call(string, function(string, character, index) {
return string + (offset.indexOf(index + 1) >= 0 ? character.toUpperCase() : character.toLowerCase());
}, '');
}
function capLetters2(string, offsets) {
var offsetMap = offsets.reduce(function (map, offset) {
map[offset - 1] = true;
return map;
}, {});
return Array.prototype.reduce.call(string, function(string, character, index) {
return string + (offsetMap[index] ? character.toUpperCase() : character.toLowerCase());
}, '');
}
var result = "";
var string = "";
Ready to run.
Test | Ops/sec | |
---|---|---|
IndexOf |
| ready |
Object |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.