OLD | NEW |
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 histogram) | 123 histogram) |
124 | 124 |
125 | 125 |
126 def readChromiumHistograms(): | 126 def readChromiumHistograms(): |
127 """Searches the Chromium source for all histogram names. | 127 """Searches the Chromium source for all histogram names. |
128 | 128 |
129 Also prints warnings for any invocations of the UMA_HISTOGRAM_* macros with | 129 Also prints warnings for any invocations of the UMA_HISTOGRAM_* macros with |
130 names that might vary during a single run of the app. | 130 names that might vary during a single run of the app. |
131 | 131 |
132 Returns: | 132 Returns: |
133 A set cotaining any found literal histogram names. | 133 A set containing any found literal histogram names. |
134 """ | 134 """ |
135 logging.info('Scanning Chromium source for histograms...') | 135 logging.info('Scanning Chromium source for histograms...') |
136 | 136 |
137 # Use git grep to find all invocations of the UMA_HISTOGRAM_* macros. | 137 # Use git grep to find all invocations of the UMA_HISTOGRAM_* macros. |
138 # Examples: | 138 # Examples: |
139 # 'path/to/foo.cc:420: UMA_HISTOGRAM_COUNTS_100("FooGroup.FooName",' | 139 # 'path/to/foo.cc:420: UMA_HISTOGRAM_COUNTS_100("FooGroup.FooName",' |
140 # 'path/to/bar.cc:632: UMA_HISTOGRAM_ENUMERATION(' | 140 # 'path/to/bar.cc:632: UMA_HISTOGRAM_ENUMERATION(' |
141 locations = commands.getoutput('git gs UMA_HISTOGRAM').split('\n') | 141 locations = commands.getoutput('git gs UMA_HISTOGRAM').split('\n') |
142 filenames = set([location.split(':')[0] for location in locations]) | 142 filenames = set([location.split(':')[0] for location in locations]) |
143 | 143 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 logging.info('Histograms in Chromium but not in XML files:') | 247 logging.info('Histograms in Chromium but not in XML files:') |
248 logging.info('-------------------------------------------------') | 248 logging.info('-------------------------------------------------') |
249 for histogram in sorted(unmapped_histograms): | 249 for histogram in sorted(unmapped_histograms): |
250 logging.info(' %s - %s', histogram, hashHistogramName(histogram)) | 250 logging.info(' %s - %s', histogram, hashHistogramName(histogram)) |
251 else: | 251 else: |
252 logging.info('Success! No unmapped histograms found.') | 252 logging.info('Success! No unmapped histograms found.') |
253 | 253 |
254 | 254 |
255 if __name__ == '__main__': | 255 if __name__ == '__main__': |
256 main() | 256 main() |
OLD | NEW |