Bug 1287938 - Make ts_paint use the parent process start time and first paint info in calculations. r=jmaher

Instead of checking for the paint time of the tspaint_test.html content,
we're now measuring the delta between process start and first paint as
reported by the parent process's startup info.

MozReview-Commit-ID: 868mf2vazwL

--HG--
extra : rebase_source : 7ba8062be91ca00ab1bbcd386b4c9213148e41f7
This commit is contained in:
Mike Conley 2016-07-20 11:00:25 -04:00
parent c513d33161
commit 7805abd00a
6 changed files with 68 additions and 20 deletions

View File

@ -6,37 +6,28 @@
<!-- Pick off begin time as a cgi argument and print it out -->
<!-- call this with an arg, e.g. file://foo/startup-test.html?begin=12345678 -->
<!-- In-line this to avoid compilation. -->
<script language="Javascript" type="text/javascript" src="chrome://talos-powers-content/content/TalosPowersContent.js"></script>
<script language="Javascript" type="text/javascript" src="../scripts/MozillaFileLogger.js"></script>
<script language="Javascript" type="text/javascript" src="../scripts/Profiler.js"></script>
<script language="JavaScript" type="text/javascript" src="../tests/quit.js"></script>
<script language="javascript" type="text/javascript">
function painted() {
var now = Date.now();
Profiler.pause();
Profiler.initFromURLQueryParams(location.search);
Profiler.finishStartupProfiling();
window.removeEventListener("MozAfterPaint", painted, true);
var startupTime = -1;
TalosPowersContent.getStartupInfo().then(function(startupInfo) {
let startupTime = startupInfo['firstPaint'] - startupInfo['process'];
try {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var startupInfo = Components.classes['@mozilla.org/toolkit/app-startup;1'].
getService(Ci.nsIAppStartup).getStartupInfo();
startupTime = now - startupInfo['process'];
} catch(ex) {
dumpLog(ex + '\n');
}
Profiler.pause();
document.body.textContent = 'Startup time = ' + startupTime + ' ms';
if (window.dump) {
dumpLog('__start_report' + startupTime + '__end_report\n\n');
}
dumpConsoleAndQuit();
document.body.textContent = 'Startup time = ' + startupTime + ' ms';
if (window.dump) {
dumpLog('__start_report' + startupTime + '__end_report\n\n');
}
dumpConsoleAndQuit();
});
}
function failed() {
@ -76,4 +67,3 @@ setTimeout(failed, 5000);
</script>
<body></body>
</html>

View File

@ -63,3 +63,20 @@ addEventListener("TalosPowersContentFocus", (e) => {
}, content);
content.dispatchEvent(new content.CustomEvent("TalosPowersContentFocused", contentEvent));
}, true, true);
addEventListener("TalosPowersContentGetStartupInfo", (e) => {
sendAsyncMessage("TalosPowersContent:GetStartupInfo");
addMessageListener("TalosPowersContent:GetStartupInfo:Result",
function onResult(msg) {
removeMessageListener("TalosPowersContent:GetStartupInfo:Result",
onResult);
let event = Cu.cloneInto({
bubbles: true,
detail: msg.data,
}, content);
content.dispatchEvent(
new content.CustomEvent("TalosPowersContentGetStartupInfoResult",
event));
});
});

View File

@ -40,6 +40,7 @@ TalosPowersService.prototype = {
Services.mm.addMessageListener("Talos:ForceQuit", this);
Services.mm.addMessageListener("TalosContentProfiler:Command", this);
Services.mm.addMessageListener("TalosPowersContent:ForceCCAndGC", this);
Services.mm.addMessageListener("TalosPowersContent:GetStartupInfo", this);
Services.obs.addObserver(this, "xpcom-shutdown", false);
},
@ -63,6 +64,9 @@ TalosPowersService.prototype = {
Cu.forceShrinkingGC();
break;
}
case "TalosPowersContent:GetStartupInfo": {
this.receiveGetStartupInfo(message);
}
}
},
@ -230,6 +234,28 @@ TalosPowersService.prototype = {
dump('Force Quit failed: ' + e);
}
},
receiveGetStartupInfo(message) {
let mm = message.target.messageManager;
let startupInfo = Services.startup.getStartupInfo();
if (!startupInfo["firstPaint"]) {
// It's possible that we were called early enough that
// the firstPaint measurement hasn't been set yet. In
// that case, we set up an observer for the next time
// a window is painted and re-retrieve the startup info.
let obs = function(subject, topic) {
Services.obs.removeObserver(this, topic);
startupInfo = Services.startup.getStartupInfo();
mm.sendAsyncMessage("TalosPowersContent:GetStartupInfo:Result",
startupInfo);
};
Services.obs.addObserver(obs, "widget-first-paint", false);
} else {
mm.sendAsyncMessage("TalosPowersContent:GetStartupInfo:Result",
startupInfo);
}
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TalosPowersService]);

View File

@ -29,5 +29,20 @@ var TalosPowersContent;
}));
},
getStartupInfo() {
return new Promise((resolve) => {
var event = new CustomEvent("TalosPowersContentGetStartupInfo", {
bubbles: true,
});
document.dispatchEvent(event);
addEventListener("TalosPowersContentGetStartupInfoResult",
function onResult(e) {
removeEventListener("TalosPowersContentGetStartupInfoResult",
onResult);
resolve(e.detail);
});
});
},
};
})();

View File

@ -4,7 +4,7 @@
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>talos-powers@mozilla.org</em:id>
<em:version>1.0.8</em:version>
<em:version>1.0.10</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>