diff options
author | Fabien Sanglard <sanglardf@google.com> | 2017-07-17 18:50:32 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-07-17 18:50:32 +0000 |
commit | 941a6a5592bae5ac3174b6e013e6e439665be21b (patch) | |
tree | 8b03ae58aa2bde01d31a83794c9f58c7a04d9130 | |
parent | 813e6cbea9062525586daca79cbeb2b09cd538f0 (diff) | |
parent | 7d8ac8767e7a3137d383939068e1dd2564e1c18f (diff) | |
download | extras-941a6a5592bae5ac3174b6e013e6e439665be21b.tar.gz |
Merge "Add event monitoring to Inferno." am: 945911cbae am: 878c04ed7d am: d9a9139b54
am: 7d8ac8767e
Change-Id: Ic3c8b7d97d43d677f921201fd65be849cc7fb5b5
-rw-r--r-- | simpleperf/inferno/inferno.py | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/simpleperf/inferno/inferno.py b/simpleperf/inferno/inferno.py index ade3e741..03cdf658 100644 --- a/simpleperf/inferno/inferno.py +++ b/simpleperf/inferno/inferno.py @@ -63,25 +63,33 @@ def collect_data(adb_client, process): unwinding_parameter = "--call-graph fp" print "Unwinding with frame pointers." + # Check whether sampling will be frequency based or event based. + sampling_parameter = "-f %s" % process.args.sample_frequency + if process.args.events: + tokens = process.args.events.split(" ") + if len(tokens) == 2: + num_events = tokens[0] + event_name = tokens[1] + sampling_parameter = "-c %s -e '%s'" % (num_events, event_name) + else: + print "Event format string not recognized. Expected \"requency event_name\"." + print "Got : [" + ",".join(tokens) + "]" + return False + print "Using event sampling (%s)." % sampling_parameter + else: + print "Using frequency sampling (%s)." % sampling_parameter + process.cmd = "./simpleperf record \ -o /data/local/tmp/perf.data \ %s \ -p %s \ --duration %s \ - -f %s" % ( + %s" % ( unwinding_parameter, process.pid, process.args.capture_duration, - process.args.sample_frequency) - - # TODO Add arg to configure what events to listen on: - # -e instructions - # -e cpu-cycles - # -e cache-references - # -e cache-misses - # -e branch-instructions - # -e branch-misses - # Also add the granularity with -c 100000 + sampling_parameter) + print("Process '%s' PID = %d" % (process.name, process.pid)) if process.args.skip_collection: @@ -257,8 +265,15 @@ def main(): parser.add_argument('-sc','--skip_collection', default=False, help='Skip data collection', action="store_true") parser.add_argument('-f', '--sample_frequency', default=6000, help='Sample frequency') parser.add_argument('-w', '--svg_width', type=int, default=1124) - parser.add_argument('-sb', '--skip_push_binary', help='Skip pushing simpleperf before profiling', default=False, action="store_true") - parser.add_argument('-du', '--dwarf_unwinding', help='Perform unwinding using dwarf instead of fp.', default=False, action='store_true') + parser.add_argument('-sb', '--skip_push_binary', help='Skip pushing simpleperf before profiling', + default=False, action="store_true") + parser.add_argument('-du', '--dwarf_unwinding', help='Perform unwinding using dwarf instead of fp.', + default=False, action='store_true') + parser.add_argument('-e', '--events', + help='Sample based on event occurences instead of frequency. ' + 'Format expected is "event_counts event_name". e.g: "10000 cpu-cyles". A few examples of \ + nmames: cpu-cycles, cache-references, cache-misses, branch-instructions, branch-misses', + default="") args = parser.parse_args() # Since we may attempt to sample privileged process, let's try to be root. |