Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Created August 3, 2017 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nolanlawson/ee1222ee2acf9756f7457fb01beac6ae to your computer and use it in GitHub Desktop.
Save nolanlawson/ee1222ee2acf9756f7457fb01beac6ae to your computer and use it in GitHub Desktop.
Promise throughput test
<!doctype html>
<html>
<button type=button onclick="runTest()">Run test</button>
<pre id=display></pre>
<script>
function runTest() {
performance.mark('start')
var p = Promise.resolve()
for (var i = 0; i < 10000; i++) {
p = p.then(function() { return 'done'; })
}
p.then(function () {
performance.mark('finish')
performance.measure('time', 'start', 'finish')
display.innerHTML += `Time: ${performance.getEntriesByType('measure').slice(-1)[0].duration}ms\n`
})
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment