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
|
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf8">
<title>Test for getRepeatId()</title>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript;version=1.8" src="head.js"></script>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
</head>
<body>
<p>Test for render perf</p>
<div id="output"></div>
<script type="text/javascript;version=1.8">
const testPackets = [];
const numMessages = 1000;
for (let id = 0; id < numMessages; id++) {
let message = "Odd text";
if (id % 2 === 0) {
message = "Even text";
}
testPackets.push({
"from": "server1.conn4.child1/consoleActor2",
"type": "consoleAPICall",
"message": {
"arguments": [
"foobar",
message,
id
],
"columnNumber": 1,
"counter": null,
"filename": "file:///test.html",
"functionName": "",
"groupName": "",
"level": "log",
"lineNumber": 1,
"private": false,
"styles": [],
"timeStamp": 1455064271115 + id,
"timer": null,
"workerType": "none",
"category": "webdev"
}
});
}
function timeit(cb) {
// Return a Promise that resolves the number of seconds cb takes.
return new Promise(resolve => {
let start = performance.now();
cb();
let elapsed = performance.now() - start;
resolve(elapsed / 1000);
});
}
window.onload = Task.async(function* () {
const { configureStore } = browserRequire("devtools/client/webconsole/new-console-output/store");
const { filterTextSet, filtersClear } = browserRequire("devtools/client/webconsole/new-console-output/actions/index");
const NewConsoleOutputWrapper = browserRequire("devtools/client/webconsole/new-console-output/new-console-output-wrapper");
const wrapper = new NewConsoleOutputWrapper(document.querySelector("#output"), {});
const store = configureStore();
let time = yield timeit(() => {
testPackets.forEach((message) => {
wrapper.dispatchMessageAdd(message);
});
});
info("took " + time + " seconds to render messages");
time = yield timeit(() => {
store.dispatch(filterTextSet("Odd text"));
});
info("took " + time + " seconds to search filter half the messages");
time = yield timeit(() => {
store.dispatch(filtersClear());
});
info("took " + time + " seconds to clear the filter");
ok(true, "Yay, it didn't time out!");
SimpleTest.finish();
});
</script>
</body>
</html>
|