Skip to content

Instantly share code, notes, and snippets.

@bmizerany
Created April 11, 2016 16:18
Show Gist options
  • Save bmizerany/4aaf7eeff724c65b88e5964df4a6338c to your computer and use it in GitHub Desktop.
Save bmizerany/4aaf7eeff724c65b88e5964df4a6338c to your computer and use it in GitHub Desktop.
<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