OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2016 The Chromium Authors. All rights reserved. | 3 Copyright 2016 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/iteration_helpers.html"> | 8 <link rel="import" href="/tracing/base/iteration_helpers.html"> |
9 <link rel="import" href="/tracing/metrics/metric_registry.html"> | 9 <link rel="import" href="/tracing/metrics/metric_registry.html"> |
10 <link rel="import" href="/tracing/value/diagnostics/diagnostic_map.html"> | 10 <link rel="import" href="/tracing/value/diagnostics/diagnostic_map.html"> |
11 <link rel="import" href="/tracing/value/histogram.html"> | 11 <link rel="import" href="/tracing/value/histogram.html"> |
12 <link rel="import" href="/tracing/value/value.html"> | 12 <link rel="import" href="/tracing/value/value.html"> |
13 | 13 |
14 <script> | 14 <script> |
15 'use strict'; | 15 'use strict'; |
16 | 16 |
17 tr.exportTo('tr.metrics', function() { | 17 tr.exportTo('tr.metrics', function() { |
18 var MEMORY_INFRA_TRACING_CATEGORY = 'disabled-by-default-memory-infra'; | 18 var MEMORY_INFRA_TRACING_CATEGORY = 'disabled-by-default-memory-infra'; |
19 | 19 |
20 var TIME_NUMERIC_BUILDER = tr.v.NumericBuilder.createExponential( | 20 var TIME_BOUNDARIES = tr.v.HistogramBinBoundaries.createExponential( |
21 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, | 21 1e-3, 1e5, 30); |
22 tr.b.Range.fromExplicitRange(1e-3, 1e5), 30); | |
23 | 22 |
24 var BYTE_NUMERIC_BUILDER = tr.v.NumericBuilder.createExponential( | 23 var BYTE_BOUNDARIES = tr.v.HistogramBinBoundaries.createExponential( |
25 tr.v.Unit.byName.sizeInBytes_smallerIsBetter, | 24 1, 1e9, 30); |
26 tr.b.Range.fromExplicitRange(1, 1e9), 30); | |
27 | 25 |
28 var COUNT_NUMERIC_BUILDER = tr.v.NumericBuilder.createExponential( | 26 var COUNT_BOUNDARIES = tr.v.HistogramBinBoundaries.createExponential( |
29 tr.v.Unit.byName.count_smallerIsBetter, | 27 1, 1e5, 30); |
30 tr.b.Range.fromExplicitRange(1, 1e5), 30); | |
31 | 28 |
32 function addTimeDurationValue(valueName, duration, allValues) { | 29 function addTimeDurationValue(valueName, duration, allValues) { |
33 var hist = TIME_NUMERIC_BUILDER.build(); | 30 var hist = new tr.v.Histogram( |
| 31 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, TIME_BOUNDARIES); |
34 hist.add(duration); | 32 hist.add(duration); |
35 allValues.addValue(new tr.v.NumericValue(valueName, hist)); | 33 allValues.addValue(new tr.v.NumericValue(valueName, hist)); |
36 } | 34 } |
37 | 35 |
38 // Adds values specific to memory-infra dumps. | 36 // Adds values specific to memory-infra dumps. |
39 function addMemoryInfraValues(values, model, categoryNamesToTotalEventSizes) { | 37 function addMemoryInfraValues(values, model, categoryNamesToTotalEventSizes) { |
40 var memoryDumpCount = model.globalMemoryDumps.length; | 38 var memoryDumpCount = model.globalMemoryDumps.length; |
41 if (memoryDumpCount === 0) | 39 if (memoryDumpCount === 0) |
42 return; | 40 return; |
43 | 41 |
(...skipping 30 matching lines...) Expand all Loading... |
74 'dump', | 72 'dump', |
75 nonMemoryInfraThreadOverhead / memoryDumpCount, values); | 73 nonMemoryInfraThreadOverhead / memoryDumpCount, values); |
76 tr.b.iterItems(overheadByProvider, function(providerName, overhead) { | 74 tr.b.iterItems(overheadByProvider, function(providerName, overhead) { |
77 addTimeDurationValue( | 75 addTimeDurationValue( |
78 'Average CPU overhead of ' + providerName + ' per OnMemoryDump call', | 76 'Average CPU overhead of ' + providerName + ' per OnMemoryDump call', |
79 overhead.duration / overhead.count, values); | 77 overhead.duration / overhead.count, values); |
80 }); | 78 }); |
81 | 79 |
82 var memoryInfraEventsSize = | 80 var memoryInfraEventsSize = |
83 categoryNamesToTotalEventSizes.get(MEMORY_INFRA_TRACING_CATEGORY); | 81 categoryNamesToTotalEventSizes.get(MEMORY_INFRA_TRACING_CATEGORY); |
84 var memoryInfraTraceBytesValue = BYTE_NUMERIC_BUILDER.build(); | 82 var memoryInfraTraceBytesValue = new tr.v.Histogram( |
| 83 tr.v.Unit.byName.sizeInBytes_smallerIsBetter, BYTE_BOUNDARIES); |
85 memoryInfraTraceBytesValue.add(memoryInfraEventsSize); | 84 memoryInfraTraceBytesValue.add(memoryInfraEventsSize); |
86 values.addValue(new tr.v.NumericValue( | 85 values.addValue(new tr.v.NumericValue( |
87 'Total trace size of memory-infra dumps in bytes', | 86 'Total trace size of memory-infra dumps in bytes', |
88 memoryInfraTraceBytesValue)); | 87 memoryInfraTraceBytesValue)); |
89 | 88 |
90 var traceBytesPerDumpValue = BYTE_NUMERIC_BUILDER.build(); | 89 var traceBytesPerDumpValue = new tr.v.Histogram( |
| 90 tr.v.Unit.byName.sizeInBytes_smallerIsBetter, BYTE_BOUNDARIES); |
91 traceBytesPerDumpValue.add(memoryInfraEventsSize / memoryDumpCount); | 91 traceBytesPerDumpValue.add(memoryInfraEventsSize / memoryDumpCount); |
92 values.addValue(new tr.v.NumericValue( | 92 values.addValue(new tr.v.NumericValue( |
93 'Average trace size of memory-infra dumps in bytes', | 93 'Average trace size of memory-infra dumps in bytes', |
94 traceBytesPerDumpValue)); | 94 traceBytesPerDumpValue)); |
95 } | 95 } |
96 | 96 |
97 function tracingMetric(values, model) { | 97 function tracingMetric(values, model) { |
98 if (!model.stats.hasEventSizesinBytes) { | 98 if (!model.stats.hasEventSizesinBytes) { |
99 throw new Error('Model stats does not have event size information. ' + | 99 throw new Error('Model stats does not have event size information. ' + |
100 'Please enable ImportOptions.trackDetailedModelStats.'); | 100 'Please enable ImportOptions.trackDetailedModelStats.'); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 ((map.get(stat.category) || 0) + | 154 ((map.get(stat.category) || 0) + |
155 stat.totalEventSizeinBytes))), new Map())); | 155 stat.totalEventSizeinBytes))), new Map())); |
156 | 156 |
157 // Determine the category with the highest total event size. | 157 // Determine the category with the highest total event size. |
158 var maxCatNameAndBytes = Array.from( | 158 var maxCatNameAndBytes = Array.from( |
159 categoryNamesToTotalEventSizes.entries()).reduce( | 159 categoryNamesToTotalEventSizes.entries()).reduce( |
160 (a, b) => (b[1] >= a[1]) ? b : a); | 160 (a, b) => (b[1] >= a[1]) ? b : a); |
161 var maxEventBytesPerCategory = maxCatNameAndBytes[1]; | 161 var maxEventBytesPerCategory = maxCatNameAndBytes[1]; |
162 var categoryWithMaxEventBytes = maxCatNameAndBytes[0]; | 162 var categoryWithMaxEventBytes = maxCatNameAndBytes[0]; |
163 | 163 |
164 var maxEventCountPerSecValue = COUNT_NUMERIC_BUILDER.build(); | 164 var maxEventCountPerSecValue = new tr.v.Histogram( |
| 165 tr.v.Unit.byName.count_smallerIsBetter, COUNT_BOUNDARIES); |
165 maxEventCountPerSecValue.add(maxEventCountPerSec); | 166 maxEventCountPerSecValue.add(maxEventCountPerSec); |
166 | 167 |
167 var maxEventBytesPerSecValue = BYTE_NUMERIC_BUILDER.build(); | 168 var maxEventBytesPerSecValue = new tr.v.Histogram( |
| 169 tr.v.Unit.byName.sizeInBytes_smallerIsBetter, BYTE_BOUNDARIES); |
168 maxEventBytesPerSecValue.add(maxEventBytesPerSec); | 170 maxEventBytesPerSecValue.add(maxEventBytesPerSec); |
169 | 171 |
170 var totalTraceBytesValue = BYTE_NUMERIC_BUILDER.build(); | 172 var totalTraceBytesValue = new tr.v.Histogram( |
| 173 tr.v.Unit.byName.sizeInBytes_smallerIsBetter, BYTE_BOUNDARIES); |
171 totalTraceBytesValue.add(totalTraceBytes); | 174 totalTraceBytesValue.add(totalTraceBytes); |
172 | 175 |
173 var biggestCategory = { | 176 var biggestCategory = { |
174 name: categoryWithMaxEventBytes, | 177 name: categoryWithMaxEventBytes, |
175 size_in_bytes: maxEventBytesPerCategory | 178 size_in_bytes: maxEventBytesPerCategory |
176 }; | 179 }; |
177 | 180 |
178 var totalBytes = new tr.v.NumericValue( | 181 var totalBytes = new tr.v.NumericValue( |
179 'Total trace size in bytes', totalTraceBytesValue); | 182 'Total trace size in bytes', totalTraceBytesValue); |
180 totalBytes.diagnostics.set( | 183 totalBytes.diagnostics.set( |
(...skipping 17 matching lines...) Expand all Loading... |
198 | 201 |
199 tr.metrics.MetricRegistry.register(tracingMetric); | 202 tr.metrics.MetricRegistry.register(tracingMetric); |
200 | 203 |
201 return { | 204 return { |
202 tracingMetric: tracingMetric, | 205 tracingMetric: tracingMetric, |
203 // For testing only: | 206 // For testing only: |
204 MEMORY_INFRA_TRACING_CATEGORY: MEMORY_INFRA_TRACING_CATEGORY | 207 MEMORY_INFRA_TRACING_CATEGORY: MEMORY_INFRA_TRACING_CATEGORY |
205 }; | 208 }; |
206 }); | 209 }); |
207 </script> | 210 </script> |
OLD | NEW |