Bug 1179732 - Make tresize dump multiprocess profiles
--- a/testing/talos/talos/startup_test/tresize/addon/content/Profiler.js
+++ b/testing/talos/talos/startup_test/tresize/addon/content/Profiler.js
@@ -14,16 +14,18 @@
// Finer grained profiler control
//
// Use this object to pause and resume the profiler so that it only profiles the
// relevant parts of our tests.
var Profiler;
(function(){
+ Components.utils.import("resource://gre/modules/osfile.jsm");
+
var _profiler;
// If this script is loaded in a framescript context, there won't be a
// document object, so just use a fallback value in that case.
var test_name = this.document ? this.document.location.pathname : "unknown";
// Whether Profiler has been initialized. Until that happens, most calls
// will be ignored.
@@ -94,20 +96,35 @@ var Profiler;
["js", "leaf", "stackwalk", "threads"], 4,
profiler_threadsArray, profiler_threadsArray.length);
if (_profiler.PauseSampling) {
_profiler.PauseSampling();
}
}
},
finishTest: function Profiler__finishTest () {
- if (_profiler && enabled) {
- _profiler.dumpProfileToFile(profiler_dir + "/" + currentTest + ".sps");
- _profiler.StopProfiler();
- }
+ return new Promise((resolve) => {
+ let profileFile = profiler_dir + "/" + currentTest + ".sps";
+
+ _profiler.getProfileDataAsync().then((profile) => {
+ let encoder = new TextEncoder();
+ let array = encoder.encode(JSON.stringify(profile));
+
+ OS.File.writeAtomic(profileFile, array, {
+ tmpPath: profileFile + ".tmp",
+ }).then(() => {
+ _profiler.StopProfiler();
+ resolve();
+ });
+ }, (error) => {
+ Cu.reportError("Failed to gather profile: " + error);
+ // FIXME: We should probably send a message down to the
+ // child which causes it to reject the waiting Promise.
+ });
+ });
},
finishStartupProfiling: function Profiler__finishStartupProfiling () {
if (_profiler && enabled) {
_profiler.dumpProfileToFile(profiler_dir + "/startup.sps");
_profiler.StopProfiler();
}
},
resume: function Profiler__resume (name, explicit) {
--- a/testing/talos/talos/startup_test/tresize/addon/content/tresize.js
+++ b/testing/talos/talos/startup_test/tresize/addon/content/tresize.js
@@ -30,33 +30,34 @@ function resizeTest() {
Profiler.resume("resize " + count);
dataSet[count] = {'start': window.performance.now()};
window.resizeTo(windowSize,windowSize);
} catch(ex) { finish([ex + '\n']); }
}
function testCompleted() {
try {
- Profiler.finishTest();
- var total = 0;
- var diffs = [];
- for (var idx = 0; idx < count; idx++) {
- var diff = dataSet[idx].end - dataSet[idx].start;
- total += diff;
- diffs.push(diff);
- }
- var average = (total/count);
- var retVal = [];
- if (dumpDataSet) {
- retVal.push('__start_reporttresize-test.html,' + diffs + '__end_report\n');
- } else {
- retVal.push('__start_report' + average + '__end_report\n');
- }
- retVal.push('__startTimestamp' + Date.now() + '__endTimestamp\n');
- finish(retVal);
+ Profiler.finishTest().then(() => {
+ var total = 0;
+ var diffs = [];
+ for (var idx = 0; idx < count; idx++) {
+ var diff = dataSet[idx].end - dataSet[idx].start;
+ total += diff;
+ diffs.push(diff);
+ }
+ var average = (total/count);
+ var retVal = [];
+ if (dumpDataSet) {
+ retVal.push('__start_reporttresize-test.html,' + diffs + '__end_report\n');
+ } else {
+ retVal.push('__start_report' + average + '__end_report\n');
+ }
+ retVal.push('__startTimestamp' + Date.now() + '__endTimestamp\n');
+ finish(retVal);
+ });
} catch(ex) { finish([ex + '\n']); }
}
function resizeCompleted() {
count++;
if (count >= max) {
testCompleted();
} else {