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 urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;
function parseWithRE(url){
var matches = urlParseRE.exec(url);
return {
hash: matches[17],
search: matches[16],
pathname: matches[13],
port: matches[12],
hostname: matches[11],
host: matches[10],
password: matches[9],
username: matches[8],
protocol: matches[4],
origin: matches[4] + "//" + matches[10],
href: url
};
}
var parser = document.createElement('a');
var url = "http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content";
function _URL(url) {
// Naive URL parser. Assumes the input URL is valid.
this.hash = "";
this.search = "";
this.pathname = "";
this.port = "";
this.hostname = "";
this.host = "";
this.password = "";
this.username = "";
this.protocol = "";
this.origin = "";
this.href = url;
var hashIdx = url.indexOf("#");
if (hashIdx > -1) {
this.hash = url.slice(hashIdx);
url = url.slice(0, hashIdx);
}
var searchIdx = url.indexOf("?");
if (searchIdx > -1) {
this.search = url.slice(searchIdx);
url = url.slice(0, searchIdx);
}
var protoIdx = url.indexOf("://") + 1;
this.protocol = url.slice(0, protoIdx);
url = url.slice(protoIdx + 2);
var slashIdx = url.indexOf("/");
if (slashIdx > -1) {
this.host = url.slice(0, slashIdx);
this.pathname = url.slice(slashIdx);
}
else {
this.host = url;
}
var userIdx = this.host.indexOf("@");
if (userIdx > -1) {
this.username = this.host.slice(0, userIdx);
this.host = this.host.slice(userIdx + 1);
}
var pwdIdx = this.username.indexOf(":");
if (pwdIdx > -1) {
this.password = this.username.slice(pwdIdx + 1);
this.username = this.username.slice(0, pwdIdx);
}
var portIdx = this.host.indexOf(":");
if (portIdx > -1) {
this.hostname = this.host.slice(0, portIdx);
this.port = this.host.slice(portIdx + 1);
}
else {
this.hostname = this.host;
}
this.origin = this.protocol + "//" + this.host;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Regex |
| ready |
createElement("a") |
| ready |
_URL |
| ready |
Native URL |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.