Last active
August 29, 2015 14:22
-
-
Save Artur-/abac860b9e6e80b3bf29 to your computer and use it in GitHub Desktop.
Measure todomvc selectall
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
var toggleAll=document.querySelector("#toggle-all"); | |
var allCheckboxes = document.querySelectorAll("ul input[type=checkbox]"); | |
var firstCheckbox = allCheckboxes[0]; | |
var lastCheckbox = allCheckboxes[allCheckboxes.length-1]; | |
waitFor = !toggleAll.checked; | |
console.log("Wait until "+waitFor); | |
var startTime = new Date(); | |
toggleAll.click(); | |
var endTime = new Date(); | |
if (firstCheckbox.checked == waitFor) { | |
console.log("Done synchronously in "+(endTime-startTime)+"ms"); | |
alert("Took "+(endTime-startTime)+"ms"); | |
} else { | |
console.log("Synchronous part done in "+(endTime-startTime)+"ms. Waiting for async part"); | |
var timer = setInterval(function() { | |
if (firstCheckbox.checked == waitFor) { | |
endTime = new Date(); | |
window.alert("Took "+(endTime-startTime)+"ms (async)"); | |
console.log("Done asynchronously in "+(endTime-startTime)+"ms"); | |
clearInterval(timer); | |
} else { | |
console.log("Still waiting"); | |
} | |
},1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment