Bug 1376605 - Refactor process payload assembly. r=gfritzsche

--HG--
extra : rebase_source : d5999242f5ea899a33327482e685491a03ed919e
This commit is contained in:
Anthony Miyaguchi 2017-08-07 19:09:04 +02:00
Родитель 394044ba25
Коммит 4dac17d5ae
1 изменённых файлов: 38 добавлений и 42 удалений

Просмотреть файл

@ -1294,51 +1294,47 @@ var Impl = {
}
// Additional payload for chrome process.
let histograms = protect(() => this.getHistograms(isSubsession, clearSubsession), {});
let keyedHistograms = protect(() => this.getKeyedHistograms(isSubsession, clearSubsession), {});
let scalars = protect(() => this.getScalars(isSubsession, clearSubsession), {});
let keyedScalars = protect(() => this.getScalars(isSubsession, clearSubsession, true), {});
let events = protect(() => this.getEvents(isSubsession, clearSubsession))
payloadObj.histograms = histograms.parent || {};
payloadObj.keyedHistograms = keyedHistograms.parent || {};
payloadObj.processes = {
parent: {
scalars: scalars.parent || {},
keyedScalars: keyedScalars.parent || {},
events: events.parent || [],
},
content: {
scalars: scalars.content,
keyedScalars: keyedScalars.content,
histograms: histograms.content,
keyedHistograms: keyedHistograms.content,
events: events.content || [],
},
extension: {
scalars: scalars.extension,
keyedScalars: keyedScalars.extension,
histograms: histograms.extension,
keyedHistograms: keyedHistograms.extension,
events: events.extension || [],
},
dynamic: {
events: events.dynamic || [],
},
let measurements = {
histograms: protect(() => this.getHistograms(isSubsession, clearSubsession), {}),
keyedHistograms: protect(() => this.getKeyedHistograms(isSubsession, clearSubsession), {}),
scalars: protect(() => this.getScalars(isSubsession, clearSubsession), {}),
keyedScalars: protect(() => this.getScalars(isSubsession, clearSubsession, true), {}),
events: protect(() => this.getEvents(isSubsession, clearSubsession)),
};
let measurementsContainGPU = Object
.keys(measurements)
.some(key => "gpu" in measurements[key]);
payloadObj.processes = {};
let processTypes = ["parent", "content", "extension", "dynamic"];
// Only include the GPU process if we've accumulated data for it.
if ("gpu" in histograms ||
"gpu" in keyedHistograms ||
"gpu" in scalars ||
"gpu" in keyedScalars) {
payloadObj.processes.gpu = {
scalars: scalars.gpu,
keyedScalars: keyedScalars.gpu,
histograms: histograms.gpu,
keyedHistograms: keyedHistograms.gpu,
events: events.gpu || [],
};
if (measurementsContainGPU) {
processTypes.push("gpu");
}
// Collect per-process measurements.
for (const processType of processTypes) {
let processPayload = {};
for (const key in measurements) {
let payloadLoc = processPayload;
// Parent histograms are added to the top-level payload object instead of the process payload.
if (processType == "parent" && (key == "histograms" || key == "keyedHistograms")) {
payloadLoc = payloadObj;
}
// Dynamic processes only collect events.
if (processType == "dynamic" && key != "events") {
continue;
}
// Process measurements can be empty, set a default value.
let defaultValue = key == "events" ? [] : {};
payloadLoc[key] = measurements[key][processType] || defaultValue;
}
// Add process measurements to payload.
payloadObj.processes[processType] = processPayload;
}
payloadObj.info = info;