Created
April 11, 2016 16:18
-
-
Save bmizerany/4aaf7eeff724c65b88e5964df4a6338c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var i = 100000 | |
var r = [] | |
var a = document.createElement('a') | |
while (i--) { | |
var s = performance.now() | |
a.href = 'https://www.google.com?q=asdf' | |
var h = a.hostname | |
var e = performance.now() | |
r.unshift(e - s) | |
} | |
var avg = r.reduce(function(p, c) { | |
return (p + c) / r.length | |
}) | |
document.write("<div>"+avg+"</div>") | |
</script> | |
<script> | |
var i = 100000 | |
var r = [] | |
var a = /^(?:\w+\:\/\/)?([^\/]+)(.*)$/ | |
while (i--) { | |
var s = performance.now() | |
var x = a.exec('https://www.google.com?q=asdf') | |
var h = x[1] | |
var e = performance.now() | |
r.unshift(e - s) | |
} | |
var avg = r.reduce(function(p, c) { | |
return (p + c) / r.length | |
}) | |
document.write("<div>"+avg+"</div>") | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment