Chromium Code Reviews| Index: tools/metrics/histograms/find_unmapped_histograms.py |
| diff --git a/tools/metrics/histograms/find_unmapped_histograms.py b/tools/metrics/histograms/find_unmapped_histograms.py |
| index 2798424c3ffb6a0dedbcdbbcfe0517120d531186..34bc1fcd4d0194caa41f163ae4d9b33e4f03a181 100644 |
| --- a/tools/metrics/histograms/find_unmapped_histograms.py |
| +++ b/tools/metrics/histograms/find_unmapped_histograms.py |
| @@ -289,6 +289,29 @@ def hashHistogramName(name): |
| return '0x' + hashlib.md5(name).hexdigest()[:16] |
| +def output_csv(unmapped_histograms, location_map): |
| + for histogram in sorted(unmapped_histograms): |
| + (filename, line_number) = location_map[histogram].split(':', 1) |
|
Ilya Sherman
2016/08/17 22:09:24
Hmm, is it really necessary to include the max-spl
|
| + print '%s,%s,%s,%s' % (filename, line_number, histogram, |
| + hashHistogramName(histogram)) |
| + |
| + |
| +def output_log(unmapped_histograms, location_map, verbose): |
| + if len(unmapped_histograms): |
| + logging.info('') |
| + logging.info('') |
| + logging.info('Histograms in Chromium but not in XML files:') |
| + logging.info('-------------------------------------------------') |
| + for histogram in sorted(unmapped_histograms): |
| + if verbose: |
| + logging.info('%s: %s - %s', location_map[histogram], histogram, |
| + hashHistogramName(histogram)) |
| + else: |
| + logging.info(' %s - %s', histogram, hashHistogramName(histogram)) |
| + else: |
| + logging.info('Success! No unmapped histograms found.') |
| + |
| + |
| def main(): |
| # Find default paths. |
| default_root = path_util.GetInputFile('/') |
| @@ -318,6 +341,11 @@ def main(): |
| default_extra_histograms_path, |
| metavar='FILE') |
| parser.add_option( |
| + '--csv', action='store_true', dest='csv', default=False, |
|
Ilya Sherman
2016/08/17 22:09:24
nit: Let's name this variable 'output_as_csv' rath
|
| + help=( |
| + 'output as csv for ease of parsing ' + |
| + '[optional, defaults to %default]')) |
| + parser.add_option( |
| '--verbose', action='store_true', dest='verbose', default=False, |
| help=( |
| 'print file position information with histograms ' + |
| @@ -345,19 +373,10 @@ def main(): |
| else: |
| logging.warning('No such file: %s', options.extra_histograms_file_location) |
| - if len(unmapped_histograms): |
| - logging.info('') |
| - logging.info('') |
| - logging.info('Histograms in Chromium but not in XML files:') |
| - logging.info('-------------------------------------------------') |
| - for histogram in sorted(unmapped_histograms): |
| - if options.verbose: |
| - logging.info('%s: %s - %s', location_map[histogram], histogram, |
| - hashHistogramName(histogram)) |
| - else: |
| - logging.info(' %s - %s', histogram, hashHistogramName(histogram)) |
| + if options.csv: |
| + output_csv(unmapped_histograms, location_map) |
| else: |
| - logging.info('Success! No unmapped histograms found.') |
| + output_log(unmapped_histograms, location_map, options.verbose) |
| if __name__ == '__main__': |