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>
splitRegex = function(str, len) {
var regex = new RegExp('[\\s\\S]{1,' + len + '}', 'g');
return str.match(regex);
}
var splitRegexCached = (function(){
var regexCache = {};
return( function(str, len) {
var regex = regexCache[len] || (regexCache[len] = new RegExp('[\\s\\S]{1,' + len + '}', 'g'));
return str.match(regex);
});
})();
function splitSlice(str, len) {
var ret = [ ];
for (var offset = 0, strLen = str.length; offset < strLen; offset += len) {
ret.push(str.slice(offset, len + offset));
}
return ret;
}
function splitSubstr(str, len) {
var ret = [ ];
for (var offset = 0, strLen = str.length; offset < strLen; offset += len) {
ret.push(str.substr(offset, len));
}
return ret;
}
function splitSubstring(str, len) {
var ret = [ ];
for (var offset = 0, strLen = str.length; offset < strLen; offset += len) {
ret.push(str.substring(offset, offset + len));
}
return ret;
}
var tinyString = (new Array(39)).join('abcdefghijklmnopqrstuvwxyz');
var shortString = (new Array(385)).join('abcdefghijklmnopqrstuvwxyz');
var mediumString = (new Array(3856)).join('abcdefghijklmnopqrstuvwxyz');
var longString = (new Array(38462)).join('abcdefghijklmnopqrstuvwxyz');
var spanArray = [6666, 2, 3339, 5, 1620, 13, 847, 22, 521, 46, 254, 88, 145];
var spanLength = spanArray.length;
var i = 0, span;
</script>
i = 0;
Ready to run.
Test | Ops/sec | |
---|---|---|
Regex |
| ready |
Regex (Cached) |
| ready |
string.Substr |
| ready |
string.Slice |
| ready |
string.substring |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.