-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperformanceTest.html
98 lines (94 loc) · 3.99 KB
/
performanceTest.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="en">
<head>
<title>EssenceJS Performance test</title>
<meta charset="UTF-8" />
<meta name="author" content="Maximilian Berkmann" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
.num {
color: red;
}
strong {
background-color: red;
}
</style>
<script type="text/javascript" src="1.1/essence.js" async defer></script>
<script type="text/javascript" async defer>
console.profile("Local script Profile");
var tree, struct;
function start () {
perfMod = true;
Essence.init();
var SbTime = 1 || asyncTime(init, "Sandbox"), completeness = false;
var mdlCompleteTime = asyncTime(function() {
setTimeout(function () {
completeness = Essence.isComplete();
$e("#mc").write(completeness);
}, 650);
setTimeout(function () {
$e("#mct").write(mdlCompleteTime + "ms");
}, 700);
});
$e("body").after("<fieldset id='log'><legend><h3>Log</h3></legend></fieldset>", true);
$e("#log").after("<p><strong>Sandbox.js init</strong>: <span class='num'>" + SbTime + "ms</span></p>", true);
$e("#log").after("<p><strong>Loading (load→pageshow)</strong>: <span class='num'>" + $G.t + "</span></p>", true);
$e("#log").after("<p><strong>Essence.applyCSS</strong>: <span class='num'>" + time(Essence.applyCSS) + "ms</span></p>", true);
$e("#log").after("<p><strong>Header change</strong>: <span class='num'>" + time(function () {
$e("header>h2").write($G.lorem.chunk(0, 5))
}) + "ms</span></p>", true);
$e("#log").after("<p><strong>Footer change</strong>: <span class='num'>" + time(function () {
$e("footer").replace("me", Essence.author);
}) + "ms</span></p>", true);
$e("#log").after("<p><strong>Log styling</strong>: <span class='num'>" + time(function () {
$e("legend > h3").setCSS("text-align", "center");
$e("#log").setStyles(["display", "inline-block", "text-align", "center", "border", "1px solid #000", "border-radius", "5px", "padding", "9px"]);
}) + "ms</span></p>", true);
$e("#log").after("<p><strong>Module completeness (<span id='mc'>" + completeness + "</span>)</strong>: <span class='num' id='mct'>" + mdlCompleteTime + "ms</span></p>", true);
tree = DomTree();
struct = DomStructure();
//wait(zone);
}
function Init (stackLayer) {
//Slower by ~100ms, changing the timeout to 0 would improve it a little but cause some ML errors to pop up more frequently
if (typeof Essence !== "undefined") {
start();
} else if (stackLayer > 3) {
console.log("Wow, hold on ! %d stack layers down !!", stackLayer);
setTimeout("Init()", 5);
} else {
console.warn("EssenceJS is not currently available !");
Init(stackLayer? stackLayer + 1: 1);
}
}
function zone () {
Essence.isComplete();
console.log(modules, Essence.loadedModules.map(function (m) {
return m.name;
}));
if (!Sandbox) {
init("Sandbox");
wait();
}
if (!BFS) {
run("Sandbox", "1.1");
wait();
}
debugger;
BFS(struct);
debugger;
}
console.profileEnd();
</script>
</head>
<body onpageshow="start();" onload="Essence.preInit();">
<article>
<header>
<h2>Header</h2>
</header>
<p>Some text</p>
<footer>By me</footer>
</article>
</body>
</html>