mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-30 14:17:36 -10:00
Set the logLimit to the number of messages we add. Bump up the number of messages to add to 4000. Iterate 25 times instead of 10. Compute the median to limit the impact of low/high spikes. MozReview-Commit-ID: 1WoiYk5pF9v
110 lines
3.2 KiB
HTML
110 lines
3.2 KiB
HTML
<!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" 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">
|
|
"use strict";
|
|
const numMessages = 4000;
|
|
const testPackets = Array.from({length: numMessages}).map((el, id) => ({
|
|
"from": "server1.conn4.child1/consoleActor2",
|
|
"type": "consoleAPICall",
|
|
"message": {
|
|
"arguments": [
|
|
"foobar",
|
|
`${id % 2 === 0 ? "Even" : "Odd"} text`,
|
|
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"
|
|
}
|
|
}));
|
|
|
|
async function timeit(cb) {
|
|
// Return a Promise that resolves the number of seconds cb takes.
|
|
let start = performance.now();
|
|
await cb();
|
|
let elapsed = performance.now() - start;
|
|
return elapsed;
|
|
}
|
|
|
|
window.onload = async function () {
|
|
// This test does costly work multiple times to have better performance data.
|
|
SimpleTest.requestLongerTimeout(3);
|
|
|
|
try {
|
|
const Services = browserRequire("Services");
|
|
Services.prefs.setIntPref("devtools.hud.loglimit", numMessages);
|
|
const NewConsoleOutputWrapper = browserRequire(
|
|
"devtools/client/webconsole/new-console-output/new-console-output-wrapper");
|
|
const EventEmitter = browserRequire("devtools/shared/event-emitter");
|
|
|
|
const wrapper = new NewConsoleOutputWrapper(
|
|
document.getElementById("output"),
|
|
{hud: EventEmitter.decorate({proxy: {}})},
|
|
{},
|
|
null,
|
|
document,
|
|
);
|
|
wrapper.init();
|
|
|
|
let times = [];
|
|
const iterations = 25;
|
|
const lastPacket = testPackets.pop();
|
|
for (let i = 0; i < iterations; i++) {
|
|
let time = await timeit(async () => {
|
|
testPackets.forEach((packet) => wrapper.dispatchMessageAdd(packet));
|
|
// Only wait for the last packet to minimize work.
|
|
await wrapper.dispatchMessageAdd(lastPacket, true);
|
|
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
});
|
|
info(`took ${time} ms to render messages`);
|
|
times.push(time);
|
|
|
|
// Clear the console
|
|
wrapper.dispatchMessagesClear();
|
|
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
}
|
|
|
|
times.sort();
|
|
let totalTime = times.reduce((sum, t) => sum + t);
|
|
let avg = totalTime / times.length;
|
|
let median = times.length % 2 !== 0
|
|
? times[Math.floor(times.length / 2)]
|
|
: (times[(times.length / 2) - 1] + times[times.length / 2]) / 2;
|
|
info(`On average, it took ${avg} ms (median ${median} ms) ` +
|
|
`to render ${numMessages} messages`);
|
|
|
|
ok(true, "Yay, it didn't time out!");
|
|
} catch (e) {
|
|
ok(false, `Error : ${e.message}
|
|
${e.stack}
|
|
`);
|
|
}
|
|
|
|
SimpleTest.finish();
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|