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

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

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