URL parse - Regex vs URL construct (v2)

Revision 2 of this benchmark created on


Setup

const href = "https://www.prace.cz/nabidka/UP-29805040718/?rps=77&searchId=85294498-1717-4efd-85ad-5c69c1bc0697"

Test runner

Ready to run.

Testing in
TestOps/sec
Regexp
var reURLInformation = new RegExp([
    '^(https?:)//', // protocol
    '(([^:/?#]*)(?::([0-9]+))?)', // host (hostname and port)
    '(/{0,1}[^?#]*)', // pathname
    '(\\?[^#]*|)', // search
    '(#.*|)$' // hash
].join(''));
var match = href.match(reURLInformation);
ready
URL constructor
var match = new URL(href).host;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.