Revision control

1
<!DOCTYPE html>
2
<html>
3
<body>
4
<div id='sandbox'></div>
5
<div id="console"></div>
6
<script src="../resources/magnitude-perf.js"></script>
7
<script>
8
9
if (window.testRunner)
10
testRunner.dumpAsText();
11
12
var list;
13
var stack;
14
var sandbox = document.getElementById('sandbox');
15
16
// Check that long sequences of combined selectors has linear performance (per styled element)
17
18
function setupList(magnitude)
19
{
20
if (sandbox.firstChild)
21
sandbox.removeChild(sandbox.firstChild);
22
list = document.createElement('ul');
23
24
for (var i = 0; i < magnitude; ++i) {
25
var li = document.createElement('li');
26
li.setAttribute('id','unique'+i); // add unique id ensure the styles are not auto-shared
27
list.appendChild(li);
28
}
29
sandbox.appendChild(list);
30
}
31
32
function setupStack(magnitude)
33
{
34
if (sandbox.firstChild)
35
sandbox.removeChild(sandbox.firstChild);
36
stack = document.createElement('div');
37
var cur = stack;
38
39
for (var i = 0; i < magnitude; ++i) {
40
var div = document.createElement('div');
41
div.setAttribute('id','unique'+i);
42
cur.appendChild(div);
43
cur = div;
44
}
45
sandbox.appendChild(stack);
46
}
47
48
function testListStyling(magnitude)
49
{
50
document.querySelectorAll("la ~ li ~ li");
51
}
52
53
function testStackStyling(magnitude)
54
{
55
document.querySelectorAll("dav div div");
56
}
57
58
Magnitude.description('Tests styling multiple combinators have linear performance');
59
Magnitude.run(setupStack, testStackStyling, Magnitude.LINEAR);
60
sandbox.removeChild(sandbox.firstChild);
61
Magnitude.run(setupList, testListStyling, Magnitude.LINEAR);
62
sandbox.removeChild(sandbox.firstChild);
63
</script>
64
</body>
65
</html>