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

Side by Side Diff: tools/perf/metrics/memory.py

Issue 22492004: Move memory-related histogram data collection to metrics/memory.py (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor change (to make what is happening more explicit) Created 7 years, 4 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 | « tools/perf/metrics/histogram.py ('k') | 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 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import sys 5 import sys
6 6
7 from metrics import Metric 7 from metrics import Metric
8 from metrics import histogram 8 from metrics import histogram
9 9
10 _HISTOGRAMS = [ 10 _HISTOGRAMS = [
(...skipping 23 matching lines...) Expand all
34 self._histogram_start_values = dict() 34 self._histogram_start_values = dict()
35 self._histogram_delta_values = dict() 35 self._histogram_delta_values = dict()
36 36
37 def Start(self, page, tab): 37 def Start(self, page, tab):
38 """Start the per-page preparation for this metric. 38 """Start the per-page preparation for this metric.
39 39
40 Here, this consists of recording the start value of all the histograms. 40 Here, this consists of recording the start value of all the histograms.
41 """ 41 """
42 for h in _HISTOGRAMS: 42 for h in _HISTOGRAMS:
43 histogram_data = histogram.GetHistogramData(h['type'], h['name'], tab) 43 histogram_data = histogram.GetHistogramData(h['type'], h['name'], tab)
44 # Histogram data may not be available
qyearsley 2013/08/12 20:57:48 Not sure if it's best not to repeat this comment b
44 if not histogram_data: 45 if not histogram_data:
45 continue 46 continue
46 self._histogram_start_values[h['name']] = histogram_data 47 self._histogram_start_values[h['name']] = histogram_data
47 48
48 def Stop(self, page, tab): 49 def Stop(self, page, tab):
49 """Prepare the results for this page. 50 """Prepare the results for this page.
50 51
51 The results are the differences between the current histogram values 52 The results are the differences between the current histogram values
52 and the values when Start() was called. 53 and the values when Start() was called.
53 """ 54 """
54 assert self._histogram_start_values, 'Must call Start() first' 55 assert self._histogram_start_values, 'Must call Start() first'
55 for h in _HISTOGRAMS: 56 for h in _HISTOGRAMS:
57 # Histogram data may not be available
58 if h['name'] not in self._histogram_start_values:
59 continue
56 histogram_data = histogram.GetHistogramData(h['type'], h['name'], tab) 60 histogram_data = histogram.GetHistogramData(h['type'], h['name'], tab)
57 self._histogram_delta_values = histogram.SubtractHistogram( 61 self._histogram_delta_values[h['name']] = histogram.SubtractHistogram(
qyearsley 2013/08/12 20:57:48 I forgot to use self._histogram_delta_values as a
58 histogram_data, self._histogram_start_values[h['name']]) 62 histogram_data, self._histogram_start_values[h['name']])
qyearsley 2013/08/12 20:57:48 Here (and in AddResults) I'm assuming that if hist
59 63
60 def AddResults(self, tab, results): 64 def AddResults(self, tab, results):
61 """Add results for this page to the results object.""" 65 """Add results for this page to the results object."""
62 assert self._histogram_delta_values, 'Must call Stop() first' 66 assert self._histogram_delta_values, 'Must call Stop() first'
63 for h in _HISTOGRAMS: 67 for h in _HISTOGRAMS:
68 # Histogram data may not be available
69 if h['name'] not in self._histogram_delta_values:
70 continue
64 histogram_data = self._histogram_delta_values[h['name']] 71 histogram_data = self._histogram_delta_values[h['name']]
65 results.Add(h['name'], h['units'], histogram_data, 72 results.Add(h['name'], h['units'], histogram_data,
66 data_type='unimportant-histogram') 73 data_type='unimportant-histogram')
67 74
68 def AddSummaryResults(self, results): 75 def AddSummaryResults(self, results):
69 """Add summary (overall) results to the results object.""" 76 """Add summary (overall) results to the results object."""
70 self._end_memory_stats = self._browser.memory_stats 77 self._end_memory_stats = self._browser.memory_stats
71 if not self._end_memory_stats['Browser']: 78 if not self._end_memory_stats['Browser']:
72 return 79 return
73 80
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 AddSummariesForProcessTypes(['Gpu'], 'gpu') 119 AddSummariesForProcessTypes(['Gpu'], 'gpu')
113 AddSummariesForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total') 120 AddSummariesForProcessTypes(['Browser', 'Renderer', 'Gpu'], 'total')
114 121
115 end_commit_charge = self._end_memory_stats['SystemCommitCharge'] 122 end_commit_charge = self._end_memory_stats['SystemCommitCharge']
116 commit_charge_difference = end_commit_charge - self._start_commit_charge 123 commit_charge_difference = end_commit_charge - self._start_commit_charge
117 results.AddSummary('commit_charge', 'kb', commit_charge_difference, 124 results.AddSummary('commit_charge', 'kb', commit_charge_difference,
118 data_type='unimportant') 125 data_type='unimportant')
119 results.AddSummary('processes', 'count', self._memory_stats['ProcessCount'], 126 results.AddSummary('processes', 'count', self._memory_stats['ProcessCount'],
120 data_type='unimportant') 127 data_type='unimportant')
121 128
OLDNEW
« no previous file with comments | « tools/perf/metrics/histogram.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698