summaryrefslogtreecommitdiffstats
path: root/chrome/tools/extract_histograms.py
diff options
context:
space:
mode:
authorinitial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-26 23:55:29 +0000
committerinitial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-26 23:55:29 +0000
commit09911bf300f1a419907a9412154760efd0b7abc3 (patch)
treef131325fb4e2ad12c6d3504ab75b16dd92facfed /chrome/tools/extract_histograms.py
parent586acc5fe142f498261f52c66862fa417c3d52d2 (diff)
downloadchromium_src-09911bf300f1a419907a9412154760efd0b7abc3.zip
chromium_src-09911bf300f1a419907a9412154760efd0b7abc3.tar.gz
chromium_src-09911bf300f1a419907a9412154760efd0b7abc3.tar.bz2
Add chrome to the repository.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools/extract_histograms.py')
-rw-r--r--chrome/tools/extract_histograms.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/tools/extract_histograms.py b/chrome/tools/extract_histograms.py
new file mode 100644
index 0000000..97008a2
--- /dev/null
+++ b/chrome/tools/extract_histograms.py
@@ -0,0 +1,56 @@
+#!/usr/bin/python
+# Copyright 2007 Google Inc. All rights reserved.
+
+"""Extract UMA histogram strings from the Chrome source.
+
+This program generates the list of known histograms we expect to see in
+the user behavior logs. It walks the Chrome source, looking for calls
+to UMA histogram macros.
+
+Run it from the chrome/browser directory like:
+ extract_histograms.py > histogram_list
+"""
+
+# TODO(evanm): get all the jankometer histogram names.
+
+__author__ = 'evanm (Evan Martin)'
+
+import os
+import re
+import sys
+
+def GrepForHistograms(path, histograms):
+ """Grep a source file for calls to histogram macros functions.
+
+ Arguments:
+ path: path to the file
+ histograms: set of histograms to add to
+ """
+
+ histogram_re = re.compile(r'HISTOGRAM_\w+\(L"(.*)"')
+ for line in open(path):
+ match = histogram_re.search(line)
+ if match:
+ histograms.add(match.group(1))
+
+def WalkDirectory(root_path, histograms):
+ for path, dirs, files in os.walk(root_path):
+ if '.svn' in dirs:
+ dirs.remove('.svn')
+ for file in files:
+ ext = os.path.splitext(file)[1]
+ if ext == '.cc':
+ GrepForHistograms(os.path.join(path, file), histograms)
+
+def main(argv):
+ histograms = set()
+
+ # Walk the source tree to process all .cc files.
+ WalkDirectory('..', histograms)
+
+ # Print out the histograms as a sorted list.
+ for histogram in sorted(histograms):
+ print histogram
+
+if '__main__' == __name__:
+ main(sys.argv)