mirror of
https://github.com/servo/servo.git
synced 2025-06-28 19:13:41 +01:00
40 lines
1,013 B
JavaScript
40 lines
1,013 B
JavaScript
print = function(o) {
|
|
console.log(o);
|
|
if (window.dump) {
|
|
window.dump(o + '\n');
|
|
}
|
|
}
|
|
|
|
function formatLine(name, t) {
|
|
print("[PERF]," + name + "," + t);
|
|
}
|
|
|
|
function printPerfTiming() {
|
|
print("[PERF] perf block start")
|
|
formatLine("testcase", window.location);
|
|
formatLine("title", document.title.replace(/,/g, ","));
|
|
var entries = performance.getEntriesByName(window.location);
|
|
for (entry in entries) {
|
|
for (key in entries[entry]) {
|
|
if (typeof entries[entry][key] === "number") {
|
|
formatLine(key, entries[entry][key]);
|
|
}
|
|
}
|
|
}
|
|
print("[PERF] perf block end")
|
|
}
|
|
|
|
if (document.readyState === "complete") {
|
|
printPerfTiming()
|
|
window.close();
|
|
} else {
|
|
window.addEventListener('load', function () {
|
|
window.setTimeout(printPerfTiming, 0);
|
|
});
|
|
var timeout = 5;
|
|
window.setTimeout(function() {
|
|
print("[PERF] Timeout after " + timeout + " min. Force stop");
|
|
printPerfTiming();
|
|
window.close();
|
|
}, timeout * 60 * 1000)
|
|
}
|