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 src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
var truncateLongStringsOld = function (s, join_char) {
if (join_char == null) {
join_char = ' ';
}
if (s == null || s === '') {
return '';
}
var wmaxlen = 10;
var words = s.split(/\s+/);
var fixed_words = [];
$.each(words, function () {
var w = this;
if (w.length <= wmaxlen) {
fixed_words.push(w);
} else {
var parts = [];
while (w.length > 0) {
if (w.length > wmaxlen) {
parts.push(w.substring(0, wmaxlen));
w = w.substring(wmaxlen);
} else {
parts.push(w);
w = '';
}
}
fixed_words.push(parts.join(join_char));
}
});
return fixed_words.join(' ');
};
truncateLongStringsNew = function (s, join_char) {
if (join_char == null) join_char = " ";
return s.replace(/\S{10}/g, "$&" + join_char);
}
truncateLongStringsFuture = function (s, join_char) {
join_char = join_char || " ";
return s.replace(/\S{10}/g, "$&" + join_char);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
old |
| ready |
new |
| ready |
future |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.