blob: 3fa45a3f3798a27d2cfc4875a1a71981a91493d7 [file] [log] [blame]
<!DOCTYPE html>
<body>
<pre id="log"></pre>
<script src="../resources/runner.js"></script>
<div id="sandbox" style="display:none"></div>
<script>
var sandbox = document.getElementById('sandbox');
var observing = false;
for (var i = 0; i < 1000; ++i)
sandbox.appendChild(document.createElement('div'));
var html = sandbox.innerHTML;
var observer = new WebKitMutationObserver(listener);
var tickledSpan = document.createElement('span');
observer.observe(tickledSpan, {attributes: true});
function resetState() {
window.start = null;
window.numRuns = 25;
window.times = [];
}
function runAgain() {
tickledSpan.setAttribute('data-foo', numRuns);
}
function listener(mutations) {
if (start) {
var time = Date.now() - start;
times.push(time);
PerfTestRunner.log(time);
}
if (numRuns-- >= 0) {
runAgain();
start = Date.now();
for (var i = 0; i < 100; ++i)
sandbox.innerHTML = html;
} else {
PerfTestRunner.logStatistics(times);
if (!observing) {
observer.observe(sandbox, {childList: true});
observing = true;
resetState();
PerfTestRunner.log('\n------------\n');
PerfTestRunner.log('Running ' + numRuns + ' times with observation');
setTimeout(runAgain, 0);
}
}
}
resetState();
PerfTestRunner.log('Running ' + numRuns + ' times without observation');
window.addEventListener('load', runAgain);
</script>
</body>