OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2017 The Chromium Authors. All rights reserved. | 3 Copyright 2017 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="import" href="/tracing/base/math.html"> | 8 <link rel="import" href="/tracing/base/math/math.html"> |
9 <link rel="import" href="/tracing/core/auditor.html"> | 9 <link rel="import" href="/tracing/core/auditor.html"> |
10 <link rel="import" href="/tracing/model/resource_usage_series.html"> | 10 <link rel="import" href="/tracing/model/resource_usage_series.html"> |
11 | 11 |
12 <script> | 12 <script> |
13 'use strict'; | 13 'use strict'; |
14 | 14 |
15 tr.exportTo('tr.e.audits', function() { | 15 tr.exportTo('tr.e.audits', function() { |
16 /** | 16 /** |
17 * Auditor that analyzes the model and, if possible, adds data to it | 17 * Auditor that analyzes the model and, if possible, adds data to it |
18 * showing CPU usage. | 18 * showing CPU usage. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // s.cpuSelfTime : cpuDuration over slice s but not its subslices. | 86 // s.cpuSelfTime : cpuDuration over slice s but not its subslices. |
87 // | 87 // |
88 // We're looking for | 88 // We're looking for |
89 // s.cpuSelfTimeRatio: average CPU usage over the area covered by | 89 // s.cpuSelfTimeRatio: average CPU usage over the area covered by |
90 // s but not any of its subslices. | 90 // s but not any of its subslices. |
91 // = s.cpuSelfTime / s.selfTime | 91 // = s.cpuSelfTime / s.selfTime |
92 if (e.selfTime === 0 || e.selfTime === undefined || | 92 if (e.selfTime === 0 || e.selfTime === undefined || |
93 e.cpuSelfTime === undefined) { | 93 e.cpuSelfTime === undefined) { |
94 continue; | 94 continue; |
95 } | 95 } |
96 var usage = tr.b.clamp(e.cpuSelfTime / e.selfTime, 0, 1); | 96 var usage = tr.b.math.clamp(e.cpuSelfTime / e.selfTime, 0, 1); |
97 | 97 |
98 // Go through the area covered by this slice but not its subslices | 98 // Go through the area covered by this slice but not its subslices |
99 // and add the cpuSelfTimeRatio contribution over this area. | 99 // and add the cpuSelfTimeRatio contribution over this area. |
100 var lastTime = e.start; | 100 var lastTime = e.start; |
101 for (var subslice of e.subSlices) { | 101 for (var subslice of e.subSlices) { |
102 result.push({usage, start: lastTime, end: subslice.start}); | 102 result.push({usage, start: lastTime, end: subslice.start}); |
103 lastTime = subslice.end; | 103 lastTime = subslice.end; |
104 } | 104 } |
105 result.push({usage, start: lastTime, end: e.end}); | 105 result.push({usage, start: lastTime, end: e.end}); |
106 } | 106 } |
107 } | 107 } |
108 return result; | 108 return result; |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 tr.c.Auditor.register(CpuUsageAuditor); | 112 tr.c.Auditor.register(CpuUsageAuditor); |
113 | 113 |
114 return { | 114 return { |
115 CpuUsageAuditor: CpuUsageAuditor | 115 CpuUsageAuditor: CpuUsageAuditor |
116 }; | 116 }; |
117 }); | 117 }); |
118 </script> | 118 </script> |
OLD | NEW |