diff options
Diffstat (limited to 'devtools/client/webconsole/new-console-output/test/chrome/test_render_perf.html')
-rw-r--r-- | devtools/client/webconsole/new-console-output/test/chrome/test_render_perf.html | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/devtools/client/webconsole/new-console-output/test/chrome/test_render_perf.html b/devtools/client/webconsole/new-console-output/test/chrome/test_render_perf.html new file mode 100644 index 000000000..d22819a2b --- /dev/null +++ b/devtools/client/webconsole/new-console-output/test/chrome/test_render_perf.html @@ -0,0 +1,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> |