Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm:
node v10.24.1
version:
master
endpoint
share
tweet
const Benchmark = require('benchmark'); const Suite = new Benchmark.Suite; const { parse, URL } = require('url'); const urlObj = (str) => { try { return new URL(str); } catch (e) { return str; } }; // add tests Suite.add('Legacy URL parse()', () => { parse('https://skk.moe/path/to/something'); parse('/path/to/something'); }).add('WHATWG URL API', () => { new URL('https://skk.moe/path/to/something'); new URL('https://skk.moe/path/to/something'); }).add('safe WHAT WG URL', () => { urlObj('https://skk.moe/path/to/something'); urlObj('/path/to/something'); }).on('cycle', function(event) { console.info(String(event.target)); }).on('complete', function() { console.info('Fastest is ' + this.filter('fastest').map('name')); }).run();
Created from: https://npm.runkit.com/
Loading…
no comments
sign in
to comment