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 link = "http://stackoverflow.com/questions/8498592/extract-root-domain-name-from-string";
var host;
function extractDomain(url) {
var domain;
//find & remove protocol (http, ftp, etc.) and get domain
if (url.indexOf("://") > -1) {
domain = url.split('/')[2];
}
else {
domain = url.split('/')[0];
}
//find & remove port number
domain = domain.split(':')[0];
return domain;
}
function url_domain(data) {
return (new URL(data)).hostname;
}
function simple_domain(url)
{
var matches = url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
return matches[1];
}
Ready to run.
Test | Ops/sec | |
---|---|---|
extractDomain |
| ready |
anchor |
| ready |
simpledomain |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.