| 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/numeric.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( |
| 21 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, |
| 22 tr.b.Range.fromExplicitRange(1e-3, 1e5), 30); |
| 23 |
| 24 var BYTE_NUMERIC_BUILDER = tr.v.NumericBuilder.createExponential( |
| 25 tr.v.Unit.byName.sizeInBytes_smallerIsBetter, |
| 26 tr.b.Range.fromExplicitRange(1, 1e9), 30); |
| 27 |
| 28 var COUNT_NUMERIC_BUILDER = tr.v.NumericBuilder.createExponential( |
| 29 tr.v.Unit.byName.count_smallerIsBetter, |
| 30 tr.b.Range.fromExplicitRange(1, 1e5), 30); |
| 31 |
| 20 function addTimeDurationValue(valueName, duration, allValues) { | 32 function addTimeDurationValue(valueName, duration, allValues) { |
| 21 var scalarNumericValue = new tr.v.ScalarNumeric( | 33 var hist = TIME_NUMERIC_BUILDER.build(); |
| 22 tr.v.Unit.byName.timeDurationInMs_smallerIsBetter, duration); | 34 hist.add(duration); |
| 23 var numericValue = new tr.v.NumericValue(valueName, scalarNumericValue); | 35 allValues.addValue(new tr.v.NumericValue(valueName, hist)); |
| 24 allValues.addValue(numericValue); | |
| 25 } | 36 } |
| 26 | 37 |
| 27 // Adds values specific to memory-infra dumps. | 38 // Adds values specific to memory-infra dumps. |
| 28 function addMemoryInfraValues(values, model, categoryNamesToTotalEventSizes) { | 39 function addMemoryInfraValues(values, model, categoryNamesToTotalEventSizes) { |
| 29 var memoryDumpCount = model.globalMemoryDumps.length; | 40 var memoryDumpCount = model.globalMemoryDumps.length; |
| 30 if (memoryDumpCount === 0) | 41 if (memoryDumpCount === 0) |
| 31 return; | 42 return; |
| 32 | 43 |
| 33 var totalOverhead = 0; | 44 var totalOverhead = 0; |
| 34 var nonMemoryInfraThreadOverhead = 0; | 45 var nonMemoryInfraThreadOverhead = 0; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 63 'dump', | 74 'dump', |
| 64 nonMemoryInfraThreadOverhead / memoryDumpCount, values); | 75 nonMemoryInfraThreadOverhead / memoryDumpCount, values); |
| 65 tr.b.iterItems(overheadByProvider, function(providerName, overhead) { | 76 tr.b.iterItems(overheadByProvider, function(providerName, overhead) { |
| 66 addTimeDurationValue( | 77 addTimeDurationValue( |
| 67 'Average CPU overhead of ' + providerName + ' per OnMemoryDump call', | 78 'Average CPU overhead of ' + providerName + ' per OnMemoryDump call', |
| 68 overhead.duration / overhead.count, values); | 79 overhead.duration / overhead.count, values); |
| 69 }); | 80 }); |
| 70 | 81 |
| 71 var memoryInfraEventsSize = | 82 var memoryInfraEventsSize = |
| 72 categoryNamesToTotalEventSizes.get(MEMORY_INFRA_TRACING_CATEGORY); | 83 categoryNamesToTotalEventSizes.get(MEMORY_INFRA_TRACING_CATEGORY); |
| 73 var memoryInfraTraceBytesValue = new tr.v.ScalarNumeric( | 84 var memoryInfraTraceBytesValue = BYTE_NUMERIC_BUILDER.build(); |
| 74 tr.v.Unit.byName.sizeInBytes_smallerIsBetter, memoryInfraEventsSize); | 85 memoryInfraTraceBytesValue.add(memoryInfraEventsSize); |
| 75 values.addValue(new tr.v.NumericValue( | 86 values.addValue(new tr.v.NumericValue( |
| 76 'Total trace size of memory-infra dumps in bytes', | 87 'Total trace size of memory-infra dumps in bytes', |
| 77 memoryInfraTraceBytesValue)); | 88 memoryInfraTraceBytesValue)); |
| 78 | 89 |
| 79 var traceBytesPerDumpValue = new tr.v.ScalarNumeric( | 90 var traceBytesPerDumpValue = BYTE_NUMERIC_BUILDER.build(); |
| 80 tr.v.Unit.byName.sizeInBytes_smallerIsBetter, | 91 traceBytesPerDumpValue.add(memoryInfraEventsSize / memoryDumpCount); |
| 81 memoryInfraEventsSize / memoryDumpCount); | |
| 82 values.addValue(new tr.v.NumericValue( | 92 values.addValue(new tr.v.NumericValue( |
| 83 'Average trace size of memory-infra dumps in bytes', | 93 'Average trace size of memory-infra dumps in bytes', |
| 84 traceBytesPerDumpValue)); | 94 traceBytesPerDumpValue)); |
| 85 } | 95 } |
| 86 | 96 |
| 87 function tracingMetric(values, model) { | 97 function tracingMetric(values, model) { |
| 88 if (!model.stats.hasEventSizesinBytes) { | 98 if (!model.stats.hasEventSizesinBytes) { |
| 89 throw new Error('Model stats does not have event size information. ' + | 99 throw new Error('Model stats does not have event size information. ' + |
| 90 'Please enable ImportOptions.trackDetailedModelStats.'); | 100 'Please enable ImportOptions.trackDetailedModelStats.'); |
| 91 } | 101 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 ((map.get(stat.category) || 0) + | 154 ((map.get(stat.category) || 0) + |
| 145 stat.totalEventSizeinBytes))), new Map())); | 155 stat.totalEventSizeinBytes))), new Map())); |
| 146 | 156 |
| 147 // Determine the category with the highest total event size. | 157 // Determine the category with the highest total event size. |
| 148 var maxCatNameAndBytes = Array.from( | 158 var maxCatNameAndBytes = Array.from( |
| 149 categoryNamesToTotalEventSizes.entries()).reduce( | 159 categoryNamesToTotalEventSizes.entries()).reduce( |
| 150 (a, b) => (b[1] >= a[1]) ? b : a); | 160 (a, b) => (b[1] >= a[1]) ? b : a); |
| 151 var maxEventBytesPerCategory = maxCatNameAndBytes[1]; | 161 var maxEventBytesPerCategory = maxCatNameAndBytes[1]; |
| 152 var categoryWithMaxEventBytes = maxCatNameAndBytes[0]; | 162 var categoryWithMaxEventBytes = maxCatNameAndBytes[0]; |
| 153 | 163 |
| 154 var maxEventCountPerSecValue = new tr.v.ScalarNumeric( | 164 var maxEventCountPerSecValue = COUNT_NUMERIC_BUILDER.build(); |
| 155 tr.v.Unit.byName.unitlessNumber_smallerIsBetter, maxEventCountPerSec); | 165 maxEventCountPerSecValue.add(maxEventCountPerSec); |
| 156 var maxEventBytesPerSecValue = new tr.v.ScalarNumeric( | 166 |
| 157 tr.v.Unit.byName.sizeInBytes_smallerIsBetter, maxEventBytesPerSec); | 167 var maxEventBytesPerSecValue = BYTE_NUMERIC_BUILDER.build(); |
| 158 var totalTraceBytesValue = new tr.v.ScalarNumeric( | 168 maxEventBytesPerSecValue.add(maxEventBytesPerSec); |
| 159 tr.v.Unit.byName.sizeInBytes_smallerIsBetter, totalTraceBytes); | 169 |
| 170 var totalTraceBytesValue = BYTE_NUMERIC_BUILDER.build(); |
| 171 totalTraceBytesValue.add(totalTraceBytes); |
| 160 | 172 |
| 161 var biggestCategory = { | 173 var biggestCategory = { |
| 162 name: categoryWithMaxEventBytes, | 174 name: categoryWithMaxEventBytes, |
| 163 size_in_bytes: maxEventBytesPerCategory | 175 size_in_bytes: maxEventBytesPerCategory |
| 164 }; | 176 }; |
| 165 | 177 |
| 166 var totalBytes = new tr.v.NumericValue( | 178 var totalBytes = new tr.v.NumericValue( |
| 167 'Total trace size in bytes', totalTraceBytesValue); | 179 'Total trace size in bytes', totalTraceBytesValue); |
| 168 totalBytes.diagnostics.set( | 180 totalBytes.diagnostics.set( |
| 169 'category_with_max_event_size', new tr.v.d.Generic(biggestCategory)); | 181 'category_with_max_event_size', new tr.v.d.Generic(biggestCategory)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 186 | 198 |
| 187 tr.metrics.MetricRegistry.register(tracingMetric); | 199 tr.metrics.MetricRegistry.register(tracingMetric); |
| 188 | 200 |
| 189 return { | 201 return { |
| 190 tracingMetric: tracingMetric, | 202 tracingMetric: tracingMetric, |
| 191 // For testing only: | 203 // For testing only: |
| 192 MEMORY_INFRA_TRACING_CATEGORY: MEMORY_INFRA_TRACING_CATEGORY | 204 MEMORY_INFRA_TRACING_CATEGORY: MEMORY_INFRA_TRACING_CATEGORY |
| 193 }; | 205 }; |
| 194 }); | 206 }); |
| 195 </script> | 207 </script> |
| OLD | NEW |