Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: perf_insights/perf_insights/mappers/weather_report_map_function.html

Issue 1772833002: Remove SystemHealthMetric (fka RAILScore) (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: fix pi test Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2015 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
6 -->
7 <link rel="import" href="/perf_insights/function_handle.html">
8 <link rel="import" href="/perf_insights/mappers/slice_cost.html">
9 <link rel="import" href="/perf_insights/mappers/thread_grouping.html">
10 <link rel="import" href="/tracing/base/iteration_helpers.html">
11 <link rel="import" href="/tracing/model/user_model/user_expectation.html">
12 <link rel="import"
13 href="/tracing/metrics/system_health/system_health_metric.html">
14 <link rel="import" href="/tracing/model/ir_coverage.html">
15
16 <script>
17 'use strict';
18
19 tr.exportTo('pi.m', function() {
20
21 function getWeatherReportFromModel(model) {
22 // Organize all UserExpectations by type and name in a tree. A node of this
23 // tree is a dict with keys |overallScore|, |scores| and optionally
24 // |subTypes|. |overallScore| and |scores| are mutually exclusive. If
25 // |overallScore| is present it contains the overall system health score of
26 // all IRs under the tree. If |scores| is present it contains an array with
27 // the IR scores of all the IRs under the tree. |subTypes| is a map from a
28 // subType (IR type, IR name) to a node.
29 var irTree = {
30 overallScore: 0
31 };
32 var allIRs = [];
33 function addIRToNode(node, ir, path) {
34 if (node.overallScore === undefined) {
35 // For a node without system health score keep the individual IR scores.
36 node.irScores = node.irScores || [];
37 node.irScores.push(tr.metrics.sh.SystemHealthMetric.forExpectation(ir));
38 }
39 if (path.length === 0)
40 return;
41 var subType = path[0];
42 node.subTypes = node.subTypes || {};
43 node.subTypes[subType] = node.subTypes[subType] || {};
44 addIRToNode(node.subTypes[subType], ir, path.slice(1));
45 }
46 model.userModel.expectations.forEach(function(ir) {
47 if (!(ir instanceof tr.model.um.UserExpectation))
48 return;
49 allIRs.push(ir);
50 var path = [
51 ir.stageTitle,
52 ir.initiatorTitle || 'Unnamed'
53 ];
54 addIRToNode(irTree, ir, path);
55 });
56 irTree.overallScore = tr.metrics.sh.SystemHealthMetric.forModel(model);
57
58 var stageTitleByGUID = getStageTitleForEventsByGUID(model, allIRs);
59 var threadGrouping = new pi.m.ThreadGrouping();
60 threadGrouping.autoInitUsingHelpers(model);
61
62 var wr = {
63 canonicalUrl: model.canonicalUrlThatCreatedThisTrace,
64 irTree: irTree,
65 irCoverage: tr.model.getIRCoverageFromModel(model),
66 sliceCosts: pi.m.getSliceCostReport(model, threadGrouping,
67 stageTitleByGUID)
68 };
69 return wr;
70 }
71
72 function getStageTitleForEventsByGUID(model, expectations) {
73 var stageTitleByGUID = {};
74 expectations.forEach(function applyAssociatedToRTN(ir) {
75 ir.associatedEvents.forEach(function applyEventToRTN(event) {
76 // Unassociated events have already been assigned to a RTN.
77 if (stageTitleByGUID[event.guid] !== undefined)
78 return;
79 stageTitleByGUID[event.guid] = ir.stageTitle;
80 }, this);
81 }, this);
82
83 model.iterateAllEvents(function storeEventToUnassociatedSet(event) {
84 if (stageTitleByGUID[event.guid] !== undefined)
85 return;
86 stageTitleByGUID[event.guid] = 'Unknown';
87 });
88 return stageTitleByGUID;
89 }
90
91 function weatherReportMapFunction(result, model) {
92 var wr = pi.m.getWeatherReportFromModel(model);
93 result.addPair('wr', wr);
94 }
95 pi.FunctionRegistry.register(weatherReportMapFunction);
96
97 return {
98 getWeatherReportFromModel: getWeatherReportFromModel,
99 weatherReportMapFunction: weatherReportMapFunction
100 };
101 });
102
103 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698