summaryrefslogtreecommitdiff
path: root/libs/hwui/tests/scripts/process_systrace.py
diff options
context:
space:
mode:
authorStan Iliev <stani@google.com>2017-04-19 15:38:06 -0400
committerStan Iliev <stani@google.com>2017-04-20 10:08:11 -0400
commit2ccaec63ff66ac7999d92b363a7093952cb17279 (patch)
tree30b241b93b37d2f5cd4fc402cf0817dc0eeb1cde /libs/hwui/tests/scripts/process_systrace.py
parent6e6f48825c2555e7e1c7da6082df1043a59dbe73 (diff)
Create helper script to parse systrace files
Create a script that can parse systrace files and calculates metrics. The example metrics are average DrawFrame and average time to record a View. Test: ran the script and compared outputs with numbers visible, when systrace file is opened in a browser. Change-Id: If37322e7838e177efb3e2e4a00cb6e97755aa453
Diffstat (limited to 'libs/hwui/tests/scripts/process_systrace.py')
-rwxr-xr-xlibs/hwui/tests/scripts/process_systrace.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/libs/hwui/tests/scripts/process_systrace.py b/libs/hwui/tests/scripts/process_systrace.py
new file mode 100755
index 000000000000..f497bf57e099
--- /dev/null
+++ b/libs/hwui/tests/scripts/process_systrace.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+import codecs, httplib, json, os, urllib, shutil, subprocess, sys, argparse
+
+upstream_git = 'https://github.com/catapult-project/catapult.git'
+
+script_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
+catapult_src_dir = os.path.join(script_dir, 'catapult-upstream')
+
+parser = argparse.ArgumentParser()
+parser.add_argument('trace_file_or_dir',
+ help='Path to trace file or directory of trace files.')
+parser.add_argument('--output_file', dest='outfile', default=os.path.join(os.getcwd(), 'mapper_output.json'),
+ help='Path to output file to store results.')
+parser.add_argument('--mapper_func', dest='func', default='AvgDrawFrame',
+ help='Name of javascript mapper function in systrace_parser.html.')
+args = parser.parse_args()
+
+# Update the source if needed.
+if not os.path.exists(catapult_src_dir):
+ # Pull the latest source from the upstream git.
+ git_args = ['git', 'clone', upstream_git, catapult_src_dir]
+ p = subprocess.Popen(git_args, stdout=subprocess.PIPE, cwd=script_dir)
+ p.communicate()
+ if p.wait() != 0:
+ print 'Failed to checkout source from upstream git.'
+ sys.exit(1)
+
+mapper_func_file = os.path.join(script_dir, 'systrace_parser.html')
+path_to_process_traces = os.path.join(catapult_src_dir, 'trace_processor/bin/process_traces')
+run_command = path_to_process_traces + " --mapper_handle " + mapper_func_file + ":" + args.func + " --output_file " + args.outfile + " " + args.trace_file_or_dir
+print run_command
+sys.exit(os.system(run_command))
+