blob: 744d5eb0c28183bae03c1248081567570314bfa8 [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="/perf_insights/wr/thread_grouping.html">
<link rel="import" href="/tracing/base/iteration_helpers.html">
<link rel="import" href="/tracing/extras/chrome/chrome_model_helper.html">
<link rel="import" href="/tracing/extras/rail/rail_interaction_record.html">
<link rel="import" href="/tracing/model/ir_coverage.html">
<link rel="import" href="/perf_insights/wr/slice_cost.html">
<script>
tr.exportTo('pi.wr', function() {
function getWeatherReportFromModel(model) {
var railTypeNameByGUID = getRAILTypeNameForEventsByGUID(model);
var threadGrouping = new pi.wr.ThreadGrouping();
threadGrouping.autoInitUsingHelpers(model);
var wr = {
ir_coverage: tr.model.getIRCoverageFromModel(model),
sliceCosts: pi.wr.getSliceCostReport(model, threadGrouping,
railTypeNameByGUID)
};
return wr;
}
function getRAILTypeNameForEventsByGUID(model) {
var railIRs = model.interaction_records.filter(function(ir) {
return ir instanceof tr.e.rail.RAILInteractionRecord;
});
var railTypeNameByGUID = {};
railIRs.forEach(function applyAssociatedToRTN(ir) {
ir.associatedEvents.forEach(function applyEventToRTN(event) {
// Unassociated events have already been assigned to a RTN.
if (railTypeNameByGUID[event.guid] !== undefined)
return;
railTypeNameByGUID[event.guid] = ir.railTypeName;
}, this);
}, this);
model.iterateAllEvents(function storeEventToUnassociatedSet(event) {
if (railTypeNameByGUID[event.guid] !== undefined)
return;
railTypeNameByGUID[event.guid] = 'unknown';
});
return railTypeNameByGUID;
}
return {
getWeatherReportFromModel: getWeatherReportFromModel
};
});
</script>