Last active
February 11, 2016 02:15
-
-
Save axemclion/4eeb743fb91302d03210 to your computer and use it in GitHub Desktop.
Latency Performance calculations for React-Worker-DOM
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 start, results = []; | |
var ITERATIONS = 100; | |
var addButton = document.querySelectorAll('.btn.btn-primary')[0]; | |
var addItem = function() { | |
if (results.length < ITERATIONS) { | |
start = performance.now(); | |
addButton.click(); | |
} else { | |
console.log('Testing done, average is %s milliseconds, all data is', results.reduce(function(a, b) { | |
return a + b; | |
}, 0) / results.length); | |
} | |
} | |
addItem(); // set the first item | |
window.setTimeout(function() { | |
var list = document.getElementsByTagName('ol')[0]; | |
new MutationObserver(function(mutations) { | |
results.push(performance.now() - start); | |
window.setTimeout(addItem, 100); | |
}).observe(list, { | |
childList: true | |
}); | |
addItem(); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment