File: process_systrace.py

package info (click to toggle)
android-platform-frameworks-base 1%3A14~beta1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 326,092 kB
  • sloc: java: 2,032,373; xml: 343,016; cpp: 304,181; python: 3,683; ansic: 2,090; sh: 1,871; makefile: 117; sed: 19
file content (34 lines) | stat: -rwxr-xr-x 1,513 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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))