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
str = "Test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test abc test test abc test...";
reg_exp = new RegExp('abc', 'g');
replaceAllRecursive = function(string, replace_what, replace_with, prevstring) {
if (prevstring && string === prevstring)
return string;
prevstring = string.replace(replace_what, replace_with);
return replaceAllRecursive(prevstring, replace_what, replace_with, string);
};
replaceAllLoopy = function(string, replace_what, replace_with) {
while(true){
var newstring = string.replace(replace_what, replace_with);
if (newstring === string) return string;
string = newstring;
}
};
String.prototype.replaceAll = function(replace_what, replace_with) {
var oldstring = this;
while (true) {
var newstring = oldstring.replace(replace_what, replace_with);
if (newstring === oldstring) return oldstring;
oldstring = newstring;
}
};
(function() {
var weiredChar = String.fromCharCode(57344);
String.prototype.replaceAllWithWeiredChar = function(replace_what, replace_with) {
var a = '';
var b = this;
do {
a = b;
b = a.replace(replace_what, weiredChar);
} while (a !== b)
do {
a = b;
b = a.replace(weiredChar, replace_with);
} while (a !== b)
return b;
};
})();
Ready to run.
Test | Ops/sec | |
---|---|---|
split & join |
| ready |
replace with inline regexp |
| ready |
replace with cached regexp |
| ready |
recursive replace() |
| ready |
iterative replace() |
| ready |
iterative replace() as String method |
| ready |
replaceAllWithWeiredChar |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.