Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | #!/usr/bin/env python |
michael@0 | 2 | # |
michael@0 | 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
michael@0 | 4 | # Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | # found in the LICENSE file. |
michael@0 | 6 | |
michael@0 | 7 | """Provides iotop/top style profiling for android. |
michael@0 | 8 | |
michael@0 | 9 | Usage: |
michael@0 | 10 | ./device_stats_monitor.py --hz=20 --duration=5 --outfile=/tmp/foo |
michael@0 | 11 | """ |
michael@0 | 12 | |
michael@0 | 13 | import optparse |
michael@0 | 14 | import os |
michael@0 | 15 | import sys |
michael@0 | 16 | import time |
michael@0 | 17 | |
michael@0 | 18 | from pylib import android_commands |
michael@0 | 19 | from pylib import device_stats_monitor |
michael@0 | 20 | from pylib import test_options_parser |
michael@0 | 21 | |
michael@0 | 22 | |
michael@0 | 23 | def main(argv): |
michael@0 | 24 | option_parser = optparse.OptionParser() |
michael@0 | 25 | option_parser.add_option('--hz', type='int', default=20, |
michael@0 | 26 | help='Number of samples/sec.') |
michael@0 | 27 | option_parser.add_option('--duration', type='int', default=5, |
michael@0 | 28 | help='Seconds to monitor.') |
michael@0 | 29 | option_parser.add_option('--outfile', default='/tmp/devicestatsmonitor', |
michael@0 | 30 | help='Location to start output file.') |
michael@0 | 31 | test_options_parser.AddBuildTypeOption(option_parser) |
michael@0 | 32 | options, args = option_parser.parse_args(argv) |
michael@0 | 33 | |
michael@0 | 34 | monitor = device_stats_monitor.DeviceStatsMonitor( |
michael@0 | 35 | android_commands.AndroidCommands(), options.hz, options.build_type) |
michael@0 | 36 | monitor.Start() |
michael@0 | 37 | print 'Waiting for %d seconds while profiling.' % options.duration |
michael@0 | 38 | time.sleep(options.duration) |
michael@0 | 39 | url = monitor.StopAndCollect(options.outfile) |
michael@0 | 40 | print 'View results in browser at %s' % url |
michael@0 | 41 | |
michael@0 | 42 | if __name__ == '__main__': |
michael@0 | 43 | sys.exit(main(sys.argv)) |