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

Side by Side Diff: tools/metrics/histograms/find_unmapped_histograms.py

Issue 504943002: A couple fixes to find_unmapped_histograms.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 # 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 """Scans the Chromium source for histograms that are absent from histograms.xml. 5 """Scans the Chromium source for histograms that are absent from histograms.xml.
6 6
7 This is a heuristic scan, so a clean run of this script does not guarantee that 7 This is a heuristic scan, so a clean run of this script does not guarantee that
8 all histograms in the Chromium source are properly mapped. Notably, field 8 all histograms in the Chromium source are properly mapped. Notably, field
9 trials are entirely ignored by this script. 9 trials are entirely ignored by this script.
10 10
(...skipping 20 matching lines...) Expand all
31 (\w*::)? # Optional namespace 31 (\w*::)? # Optional namespace
32 k[A-Z] # Match a constant identifier: 'k' followed by an uppercase letter 32 k[A-Z] # Match a constant identifier: 'k' followed by an uppercase letter
33 \w* # Match the rest of the constant identifier 33 \w* # Match the rest of the constant identifier
34 $ # Make sure there's only the identifier, nothing else 34 $ # Make sure there's only the identifier, nothing else
35 """, re.VERBOSE) 35 """, re.VERBOSE)
36 HISTOGRAM_REGEX = re.compile(r""" 36 HISTOGRAM_REGEX = re.compile(r"""
37 UMA_HISTOGRAM # Match the shared prefix for standard UMA histogram macros 37 UMA_HISTOGRAM # Match the shared prefix for standard UMA histogram macros
38 \w* # Match the rest of the macro name, e.g. '_ENUMERATION' 38 \w* # Match the rest of the macro name, e.g. '_ENUMERATION'
39 \( # Match the opening parenthesis for the macro 39 \( # Match the opening parenthesis for the macro
40 \s* # Match any whitespace -- especially, any newlines 40 \s* # Match any whitespace -- especially, any newlines
41 ([^,]*) # Capture the first parameter to the macro 41 ([^,\)]*) # Capture the first parameter to the macro
Ilya Sherman 2014/08/26 00:27:24 Hmm, do you really need to escape the paren within
Alexei Svitkine (slow) 2014/08/29 22:42:11 You're right, it wasn't necessary. Done.
42 , # Match the comma that delineates the first parameter 42 , # Match the comma that delineates the first parameter
Ilya Sherman 2014/08/26 00:27:24 Does this not need to be updated to allow for a pa
Alexei Svitkine (slow) 2014/08/29 22:42:11 Done.
43 """, re.VERBOSE) 43 """, re.VERBOSE)
44 44
45 45
46 class DirectoryNotFoundException(Exception): 46 class DirectoryNotFoundException(Exception):
47 """Base class to distinguish locally defined exceptions from standard ones.""" 47 """Base class to distinguish locally defined exceptions from standard ones."""
48 def __init__(self, msg): 48 def __init__(self, msg):
49 self.msg = msg 49 self.msg = msg
50 50
51 def __str__(self): 51 def __str__(self):
52 return self.msg 52 return self.msg
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 '"FakeHistogram" + variant' 106 '"FakeHistogram" + variant'
107 107
108 Returns: 108 Returns:
109 None 109 None
110 """ 110 """
111 # Ignore histogram macros, which typically contain backslashes so that they 111 # Ignore histogram macros, which typically contain backslashes so that they
112 # can be formatted across lines. 112 # can be formatted across lines.
113 if '\\' in histogram: 113 if '\\' in histogram:
114 return 114 return
115 115
116 # Field trials are unique within a session, so are effectively constants.
117 if histogram.startswith('base::FieldTrial::MakeName'):
118 return
119
120 # Ignore histogram names that have been pulled out into C++ constants. 116 # Ignore histogram names that have been pulled out into C++ constants.
121 if CONSTANT_REGEX.match(histogram): 117 if CONSTANT_REGEX.match(histogram):
122 return 118 return
123 119
124 # TODO(isherman): This is still a little noisy... needs further filtering to 120 # TODO(isherman): This is still a little noisy... needs further filtering to
125 # reduce the noise. 121 # reduce the noise.
126 logging.warning('%s contains non-literal histogram name <%s>', filename, 122 logging.warning('%s contains non-literal histogram name <%s>', filename,
127 histogram) 123 histogram)
128 124
129 125
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 logging.info('Histograms in Chromium but not in XML files:') 247 logging.info('Histograms in Chromium but not in XML files:')
252 logging.info('-------------------------------------------------') 248 logging.info('-------------------------------------------------')
253 for histogram in sorted(unmapped_histograms): 249 for histogram in sorted(unmapped_histograms):
254 logging.info(' %s - %s', histogram, hashHistogramName(histogram)) 250 logging.info(' %s - %s', histogram, hashHistogramName(histogram))
255 else: 251 else:
256 logging.info('Success! No unmapped histograms found.') 252 logging.info('Success! No unmapped histograms found.')
257 253
258 254
259 if __name__ == '__main__': 255 if __name__ == '__main__':
260 main() 256 main()
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