blob: 3afc3256fe80c3b660dd81039c48498c1f09f00b [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="../resources/runner.js"></script>
</head>
<body>
<div id="wrapper">
<h2>Selected</h2>
<div id="selected"></div>
<h2>NonSelected</h2>
<div id="nonselected"></div>
</div>
<script>
var numDivsInHost = 100;
var typeNames = ['A', 'B', 'C'];
var array = new Array(numDivsInHost);
function setup()
{
var nDivs = numDivsInHost;
var nonSelected = document.getElementById('nonselected');
for (var i = 0; i < nDivs; ++i) {
var div = document.createElement('div');
div.appendChild(document.createTextNode('div' + i));
div.className = typeNames[i % typeNames.length]
array[i] = div;
nonSelected.appendChild(div);
}
}
function run()
{
var nDivs = numDivsInHost;
var array = window.array;
var selected = document.getElementById('selected');
var nonSelected = document.getElementById('nonselected');
for (var i = 0; i < 100; ++i) {
for (var j = 0; j < typeNames.length; ++j) {
for (var k = 0; k < nDivs; ++k) {
if (array[k].className == typeNames[j])
selected.appendChild(array[k]);
else
nonSelected.appendChild(array[k]);
}
selected.offsetLeft;
nonSelected.offsetLeft;
}
}
}
function done()
{
wrapper.innerHTML = '';
}
setup();
PerfTestRunner.measureTime({
description: "Measure distribution and layout performance when we do the almost same thing as select attribute of content element is changed using JavaScript",
run: run,
done: done
});
</script>
</body>
</html>