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 re = RegExp("test[123]", "g");
var indexOfStringReplace = function(val) {
if (val.indexOf("test1") != -1)
{
val.replace("test1", "");
}
else if (val.indexOf("test2") != -1)
{
val.replace("test2", "");
}
if (val.indexOf("test3") != -1)
{
val.replace("test3", "");
}
};
var regexReplace = function(val) {
if (val.indexOf("test", 0) != -1)
{
val.replace(re, "");
}
};
var greedyRegexReplace = function(val) {
if (val.indexOf("test", 0) != -1)
{
val.replace(re2, "");
}
};
var chainedReplace = function(val) {
if (val.indexOf("test", 0) != -1)
{
val.replace("test1", "").replace("test2", "").replace("test3", "");
}
};
var splitJoin = function(val) {
if (val.indexOf("test", 0) != -1)
{
val = val.split("test1").join("").split("test2").join("").split("test3").join("");
}
};
var splitJoinRegex = function(val) {
if (val.indexOf("test", 0) != -1)
{
val = val.split(re).join("");
}
};
Ready to run.
Test | Ops/sec | |
---|---|---|
indexOf String replace |
| ready |
regex replace |
| ready |
chained replace |
| ready |
splitJoin |
| ready |
splitJoin regex |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.