blob: e57613c6be01171c569dfd74be599295e6a49d48 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/base/base.html">
<link rel="import" href="/base/xhr.html">
<link rel="import" href="/base/iteration_helpers.html">
<link rel="import" href="/extras/deep_reports/scalar_value.html">
<link rel="import" href="/extras/deep_reports/rail_deep_reporter.html">
<link rel="import" href="/extras/chrome/chrome_model_helper.html">
<script>
'use strict';
tr.exportTo('tr.e.deep_reports', function() {
/**
* Runs deep reports on the provided files, and pushes telemetry-style
* values to the results object.
*/
function main(results, filesInDir) {
var lastP = new Promise(function(resolve) { resolve(); });
filesInDir.forEach(function(filename) {
// TODO(nduca): Make this like telemetry page.
var page = {
url: filename
};
lastP = lastP.then(function() {
return loadModelFromFileAsync(filename);
});
lastP = lastP.then(function(model) {
processModel(results, page, model);
});
});
return lastP;
}
function loadModelFromFileAsync(filename) {
return tr.b.getAsync(filename).then(function(trace) {
var io = new tr.ImportOptions();
io.shiftWorldToZero = true;
io.pruneEmptyContainers = false;
var m = new tr.Model();
try {
m.importTraces([trace], io);
} catch (e) {
throw new Error('While loading ' + filename + ' got: ' + e.toString());
}
return m;
});
}
function processModel(results, page, model) {
/* TODO(nduca): Need eakeufner's Telemetry value system here so we can
* be smart in aggregating results.
*/
results.addValue(tr.e.deep_reports.ScalarValue.fromDict(page, {
type: 'scalar',
name: 'numProcesses', units: 'processes', important: true,
value: model.numProcesses
}));
tr.e.deep_reports.RAILDeepReporter.addResultsForModel(results, page, model);
if (tr.e.audits.ChromeModelHelper.supportsModel(model)) {
var helper = new tr.e.audits.ChromeModelHelper(model);
if (false) {
var latencyEvents = helper.browserHelper.getLatencyEventsInRange(
model.bounds);
window.allTitles = window.allTitles || {};
latencyEvents.forEach(function(event) {
window.allTitles[event.title] = true;
});
}
}
}
return {
main: main
};
});
</script>