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
<script>
function splitRegex(str, len) {
var regex = new RegExp('.{1,' + len + '}', 'g');
return str.match(regex);
}
function splitSlice(str, len) {
var _size = Math.ceil(str.length/len),
ret = new Array(_size)
for (var offset = 0, strLen = str.length; offset < strLen; offset += len) {
ret.push(str.slice(offset, len + offset));
}
return ret;
}
// splitSlice2 ftw
// https://github.com/naomik
function splitSlice2(str, len) {
var _size = Math.ceil(str.length/len),
_ret = new Array(_size)
;
for (var _i=0; _i<_size; _i++) {
_ret[_i] = str.substring(_i*len, len);
}
return _ret;
}
var shortString = 'abcdefg';
var longString = (new Array(500)).join('qwertyuiopasdfghjklzxcvbnm');
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Regex w/ Short String |
| ready |
Slice w/ Short String |
| ready |
Slice2 w/ Short String |
| ready |
Regex w/ Long String |
| ready |
Slice w/ Long String |
| ready |
Slice2 w/ Long String |
| ready |
Regex w/ Long String, Large Chunks |
| ready |
Slice w/ Long String, Large Chunks |
| ready |
Slice2 w/ Large String, Large Chunks |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.