summaryrefslogtreecommitdiffstats
path: root/utils/perf-training/perf-helper.py
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-12-30 11:49:41 +0000
committerdim <dim@FreeBSD.org>2015-12-30 11:49:41 +0000
commit3176e97f130184ece0e1a21352c8124cc83ff24a (patch)
tree0a5b74c0b9ca73aded34df95c91fcaf3815230d8 /utils/perf-training/perf-helper.py
parent1e9b8d38881c3213d1e67b0c47ab9b2c00721a5c (diff)
downloadFreeBSD-src-3176e97f130184ece0e1a21352c8124cc83ff24a.zip
FreeBSD-src-3176e97f130184ece0e1a21352c8124cc83ff24a.tar.gz
Vendor import of clang trunk r256633:
https://llvm.org/svn/llvm-project/cfe/trunk@256633
Diffstat (limited to 'utils/perf-training/perf-helper.py')
-rw-r--r--utils/perf-training/perf-helper.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/utils/perf-training/perf-helper.py b/utils/perf-training/perf-helper.py
new file mode 100644
index 0000000..4488011
--- /dev/null
+++ b/utils/perf-training/perf-helper.py
@@ -0,0 +1,46 @@
+#===- perf-helper.py - Clang Python Bindings -----------------*- python -*--===#
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#===------------------------------------------------------------------------===#
+
+import sys
+import os
+import subprocess
+
+def findProfrawFiles(path):
+ profraw_files = []
+ for root, dirs, files in os.walk(path):
+ for filename in files:
+ if filename.endswith(".profraw"):
+ profraw_files.append(os.path.join(root, filename))
+ return profraw_files
+
+def clean(args):
+ if len(args) != 1:
+ print 'Usage: %s clean <path>\n\tRemoves all *.profraw files from <path>.' % __file__
+ return 1
+ for profraw in findProfrawFiles(args[0]):
+ os.remove(profraw)
+ return 0
+
+def merge(args):
+ if len(args) != 3:
+ print 'Usage: %s clean <llvm-profdata> <output> <path>\n\tMerges all profraw files from path into output.' % __file__
+ return 1
+ cmd = [args[0], 'merge', '-o', args[1]]
+ cmd.extend(findProfrawFiles(args[2]))
+ subprocess.check_call(cmd)
+ return 0
+
+commands = {'clean' : clean, 'merge' : merge}
+
+def main():
+ f = commands[sys.argv[1]]
+ sys.exit(f(sys.argv[2:]))
+
+if __name__ == '__main__':
+ main()
OpenPOWER on IntegriCloud