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

Side by Side Diff: tracing/tracing/metrics/tracing_metric.html

Issue 2700163002: Make some small style cleanups in tracing_metric.html (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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">
(...skipping 18 matching lines...) Expand all
29 var hist = new tr.v.Histogram(histogramName, 29 var hist = new tr.v.Histogram(histogramName,
30 tr.b.Unit.byName.timeDurationInMs_smallerIsBetter, TIME_BOUNDARIES); 30 tr.b.Unit.byName.timeDurationInMs_smallerIsBetter, TIME_BOUNDARIES);
31 hist.addSample(duration); 31 hist.addSample(duration);
32 histograms.addHistogram(hist); 32 histograms.addHistogram(hist);
33 } 33 }
34 34
35 // Adds histograms specific to memory-infra dumps. 35 // Adds histograms specific to memory-infra dumps.
36 function addMemoryInfraHistograms( 36 function addMemoryInfraHistograms(
37 histograms, model, categoryNamesToTotalEventSizes) { 37 histograms, model, categoryNamesToTotalEventSizes) {
38 var memoryDumpCount = model.globalMemoryDumps.length; 38 var memoryDumpCount = model.globalMemoryDumps.length;
39 if (memoryDumpCount === 0) 39 if (memoryDumpCount === 0) return;
40 return;
41 40
42 var totalOverhead = 0; 41 var totalOverhead = 0;
43 var nonMemoryInfraThreadOverhead = 0; 42 var nonMemoryInfraThreadOverhead = 0;
44 var overheadByProvider = {}; 43 var overheadByProvider = {};
45 tr.b.iterItems(model.processes, function(pid, process) { 44 for (var process of tr.b.dictionaryValues(model.processes)) {
46 tr.b.iterItems(process.threads, function(tid, thread) { 45 for (var thread of tr.b.dictionaryValues(process.threads)) {
47 tr.b.iterItems(thread.sliceGroup.slices, (unusedSliceId, slice) => { 46 for (var slice of tr.b.dictionaryValues(thread.sliceGroup.slices)) {
48 if (slice.category !== MEMORY_INFRA_TRACING_CATEGORY) 47 if (slice.category !== MEMORY_INFRA_TRACING_CATEGORY) return;
49 return; 48
50 totalOverhead += slice.duration; 49 totalOverhead += slice.duration;
51 if (thread.name !== 'MemoryInfra') 50 if (thread.name !== 'MemoryInfra')
52 nonMemoryInfraThreadOverhead += slice.duration; 51 nonMemoryInfraThreadOverhead += slice.duration;
53 if (slice.args && slice.args['dump_provider.name']) { 52 if (slice.args && slice.args['dump_provider.name']) {
54 var providerName = slice.args['dump_provider.name']; 53 var providerName = slice.args['dump_provider.name'];
55 var durationAndCount = overheadByProvider[providerName]; 54 var durationAndCount = overheadByProvider[providerName];
56 if (durationAndCount === undefined) { 55 if (durationAndCount === undefined) {
57 overheadByProvider[providerName] = durationAndCount = 56 overheadByProvider[providerName] = durationAndCount =
58 {duration: 0, count: 0}; 57 {duration: 0, count: 0};
59 } 58 }
60 durationAndCount.duration += slice.duration; 59 durationAndCount.duration += slice.duration;
61 durationAndCount.count++; 60 durationAndCount.count++;
62 } 61 }
63 }); 62 }
64 }); 63 }
65 }); 64 }
66 65
67 addTimeDurationHistogram( 66 addTimeDurationHistogram(
68 'Average CPU overhead on all threads per memory-infra dump', 67 'Average CPU overhead on all threads per memory-infra dump',
69 totalOverhead / memoryDumpCount, histograms); 68 totalOverhead / memoryDumpCount, histograms);
70 addTimeDurationHistogram( 69 addTimeDurationHistogram(
71 'Average CPU overhead on non-memory-infra threads per memory-infra ' + 70 'Average CPU overhead on non-memory-infra threads per memory-infra ' +
72 'dump', 71 'dump',
73 nonMemoryInfraThreadOverhead / memoryDumpCount, histograms); 72 nonMemoryInfraThreadOverhead / memoryDumpCount, histograms);
74 tr.b.iterItems(overheadByProvider, function(providerName, overhead) { 73 for (var [providerName, overhead] of Object.entries(overheadByProvider)) {
75 addTimeDurationHistogram( 74 addTimeDurationHistogram(
76 'Average CPU overhead of ' + providerName + ' per OnMemoryDump call', 75 'Average CPU overhead of ' + providerName + ' per OnMemoryDump call',
77 overhead.duration / overhead.count, histograms); 76 overhead.duration / overhead.count, histograms);
78 }); 77 }
79 78
80 var memoryInfraEventsSize = 79 var memoryInfraEventsSize =
81 categoryNamesToTotalEventSizes.get(MEMORY_INFRA_TRACING_CATEGORY); 80 categoryNamesToTotalEventSizes.get(MEMORY_INFRA_TRACING_CATEGORY);
82 var memoryInfraTraceBytesValue = new tr.v.Histogram( 81 var memoryInfraTraceBytesValue = new tr.v.Histogram(
83 'Total trace size of memory-infra dumps in bytes', 82 'Total trace size of memory-infra dumps in bytes',
84 tr.b.Unit.byName.sizeInBytes_smallerIsBetter, BYTE_BOUNDARIES); 83 tr.b.Unit.byName.sizeInBytes_smallerIsBetter, BYTE_BOUNDARIES);
85 memoryInfraTraceBytesValue.addSample(memoryInfraEventsSize); 84 memoryInfraTraceBytesValue.addSample(memoryInfraEventsSize);
86 histograms.addHistogram(memoryInfraTraceBytesValue); 85 histograms.addHistogram(memoryInfraTraceBytesValue);
87 86
88 var traceBytesPerDumpValue = new tr.v.Histogram( 87 var traceBytesPerDumpValue = new tr.v.Histogram(
89 'Average trace size of memory-infra dumps in bytes', 88 'Average trace size of memory-infra dumps in bytes',
90 tr.b.Unit.byName.sizeInBytes_smallerIsBetter, BYTE_BOUNDARIES); 89 tr.b.Unit.byName.sizeInBytes_smallerIsBetter, BYTE_BOUNDARIES);
91 traceBytesPerDumpValue.addSample(memoryInfraEventsSize / memoryDumpCount); 90 traceBytesPerDumpValue.addSample(memoryInfraEventsSize / memoryDumpCount);
92 histograms.addHistogram(traceBytesPerDumpValue); 91 histograms.addHistogram(traceBytesPerDumpValue);
93 } 92 }
94 93
95 function tracingMetric(histograms, model) { 94 function tracingMetric(histograms, model) {
96 if (!model.stats.hasEventSizesinBytes) { 95 if (!model.stats.hasEventSizesinBytes) {
97 throw new Error('Model stats does not have event size information. ' + 96 throw new Error('Model stats does not have event size information. ' +
98 'Please enable ImportOptions.trackDetailedModelStats.'); 97 'Please enable ImportOptions.trackDetailedModelStats.');
99 } 98 }
100 99
101 var eventStats = model.stats.allTraceEventStatsInTimeIntervals; 100 var eventStats = model.stats.allTraceEventStatsInTimeIntervals;
102 eventStats.sort(function(a, b) { 101 eventStats.sort((a, b) => a.timeInterval - b.timeInterval);
103 return a.timeInterval - b.timeInterval;
104 });
105 102
106 var totalTraceBytes = eventStats.reduce((a, b) => 103 var totalTraceBytes = eventStats.reduce(
107 (a + b.totalEventSizeinBytes), 0); 104 (a, b) => a + b.totalEventSizeinBytes, 0);
108 105
109 // We maintain a sliding window of records [start ... end-1] where end 106 // We maintain a sliding window of records [start ... end-1] where end
110 // increments each time through the loop, and we move start just far enough 107 // increments each time through the loop, and we move start just far enough
111 // to keep the window less than 1 second wide. Note that we need to compute 108 // to keep the window less than 1 second wide. Note that we need to compute
112 // the number of time intervals (i.e. units that timeInterval is given in) 109 // the number of time intervals (i.e. units that timeInterval is given in)
113 // in one second to know how wide the sliding window should be. 110 // in one second to know how wide the sliding window should be.
114 var maxEventCountPerSec = 0; 111 var maxEventCountPerSec = 0;
115 var maxEventBytesPerSec = 0; 112 var maxEventBytesPerSec = 0;
116 var INTERVALS_PER_SEC = Math.floor( 113 var INTERVALS_PER_SEC = Math.floor(
117 1000 / model.stats.TIME_INTERVAL_SIZE_IN_MS); 114 1000 / model.stats.TIME_INTERVAL_SIZE_IN_MS);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 191
195 tr.metrics.MetricRegistry.register(tracingMetric); 192 tr.metrics.MetricRegistry.register(tracingMetric);
196 193
197 return { 194 return {
198 tracingMetric, 195 tracingMetric,
199 // For testing only: 196 // For testing only:
200 MEMORY_INFRA_TRACING_CATEGORY, 197 MEMORY_INFRA_TRACING_CATEGORY,
201 }; 198 };
202 }); 199 });
203 </script> 200 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698