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
String.isString = function(value) {
// Nothing except a String should have both of these prototypes
// This is untrue: TemplateInstance can have both functions. The line below has been replaced with a different approach.
// return !!(value != null && value.substring && value.substr);
return typeof value === 'string' || value instanceof String;
// More Proper way to do this would be
// return Object.prototype.toString.call(object) === "[object String]";
// But this is significatantly slower on pretty much everything except "Chrome"
};
function splitAndResolveSlow(role, template) {
//var type = kindOf(role);
var roles;
//if(type === 'string') roles = role.split(/(?:\s*,\s*)|(?:\s+)/);
//else if(type === 'array') roles = role;
if(String.isString(role)) roles = role.split(/(?:\s*,\s*)|(?:\s+)/);
else if(Array.isArray(role)) roles = role;
else return role;
for(var i = roles.length - 1;i >= 0;i--) {
roles[i] = roles[i];
}
return roles;
}
function splitAndResolveFast(role, template) {
let roles;
if (typeof role === 'string') {
roles = role.split(/\s*,\s*|\s+/);
} else if (Array.isArray(role)) {
roles = role;
} else {
return role;
}
for (let i = 0; i < roles.length; ++i) {
roles[i] = roles[i];
}
return roles;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Wrapped |
| ready |
Unwrapped |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.