media/webrtc/trunk/build/android/device_stats_monitor.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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))

mercurial