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