Skip to content

Instantly share code, notes, and snippets.

@johnsonjo4531
Last active September 22, 2017 21:32
Show Gist options
  • Save johnsonjo4531/5e79eca32a6b32d51fea302d89d5ccf9 to your computer and use it in GitHub Desktop.
Save johnsonjo4531/5e79eca32a6b32d51fea302d89d5ccf9 to your computer and use it in GitHub Desktop.
Chrome 63 Async Iteration inspector performance problem

Chrome Canary 63 seems to be having a performance problem running the following code when the inspector/console is open in chrome. To recreate open the html page open the console then refresh it then halts all execution.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="script.js"></script>
<style>
body {
padding: 20px;
font-family: Arial, Helvetica, sans-serif;
}
#out {
font-size: 4em;
}
</style>
</head>
<body>
<p>
This page will hang when the console is open on startup in chrome canary 63. Try interacting with it with and without the console on startup.
</p>
<button id="count">Increment</button>
<div id="out">0</div>
<script>
var count = 0;
document.getElementById("count").addEventListener("click", ()=>{
document.getElementById("out").innerHTML = ++count;
});
</script>
</body>
</html>
async function* asyncRange(from, to) {
for (let i = from; i < to; i++) {
yield i;
}
}
async function main() {
let total = 0;
const iter = asyncRange(0, 550000);
while (true) {
const result = await iter.next();
if (result.done) break;
total += result.value;
}
console.log(total);
}
main()
@johnsonjo4531
Copy link
Author

@johnsonjo4531
Copy link
Author

Related link and source of script.js code: tc39/proposal-async-iteration#112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment