forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 0
/
native-memory-snapshot.html
76 lines (67 loc) · 1.92 KB
/
native-memory-snapshot.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<html>
<head>
<style type="text/css">
span {
color:red;
width: 100px;
height: 20px;
}
div {
color:blue;
width: 50px;
height: 10px;
}
</style>
<script src="../../LayoutTests/http/tests/inspector/inspector-test.js"></script>
<script src="performance-test.js"></script>
<script>
function test()
{
function performanceTest(timer)
{
var testName = /([^\/]+)\.html$/.exec(WebInspector.inspectedPageURL)[1];
var takeTimerCookie = timer.start("take");
MemoryAgent.getProcessMemoryDistribution(dump);
function dump(e, data)
{
timer.finish(takeTimerCookie);
function reportSize(data)
{
timer.reportSize(data.name, data.size);
if (data.children) {
for (var i = 0; i < data.children.length; ++i)
reportSize(data.children[i]);
}
}
reportSize(data);
var knownSize = 0;
for (var i = 0; i < data.children.length; ++i)
knownSize += data.children[i].size;
timer.reportSize("Unknown", data.size - knownSize);
timer.done(testName);
}
}
InspectorTest.runPerformanceTest(performanceTest, 2000);
}
function createDOMTree(elementsCount)
{
var root = document.getElementById("testTreeRoot");
for (var i = 0; i < elementsCount; ++i) {
var span = document.createElement("span");
span.id = "span_" + i;
span.style.width = "10px";
root.appendChild(span);
}
for (var i = 0; i < elementsCount; ++i)
root.appendChild(document.createElement("div"));
for (var i = 0; i < elementsCount; ++i)
root.appendChild(document.createElement("a"));
}
setTimeout(createDOMTree.bind(null,1000), 0);
</script>
</head>
<body onload="runTest()">
<div id="testTreeRoot">
</div>
</body>
</html>