1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/webrtc/trunk/build/android/device_stats_monitor.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,43 @@ 1.4 +#!/usr/bin/env python 1.5 +# 1.6 +# Copyright (c) 2012 The Chromium Authors. All rights reserved. 1.7 +# Use of this source code is governed by a BSD-style license that can be 1.8 +# found in the LICENSE file. 1.9 + 1.10 +"""Provides iotop/top style profiling for android. 1.11 + 1.12 +Usage: 1.13 + ./device_stats_monitor.py --hz=20 --duration=5 --outfile=/tmp/foo 1.14 +""" 1.15 + 1.16 +import optparse 1.17 +import os 1.18 +import sys 1.19 +import time 1.20 + 1.21 +from pylib import android_commands 1.22 +from pylib import device_stats_monitor 1.23 +from pylib import test_options_parser 1.24 + 1.25 + 1.26 +def main(argv): 1.27 + option_parser = optparse.OptionParser() 1.28 + option_parser.add_option('--hz', type='int', default=20, 1.29 + help='Number of samples/sec.') 1.30 + option_parser.add_option('--duration', type='int', default=5, 1.31 + help='Seconds to monitor.') 1.32 + option_parser.add_option('--outfile', default='/tmp/devicestatsmonitor', 1.33 + help='Location to start output file.') 1.34 + test_options_parser.AddBuildTypeOption(option_parser) 1.35 + options, args = option_parser.parse_args(argv) 1.36 + 1.37 + monitor = device_stats_monitor.DeviceStatsMonitor( 1.38 + android_commands.AndroidCommands(), options.hz, options.build_type) 1.39 + monitor.Start() 1.40 + print 'Waiting for %d seconds while profiling.' % options.duration 1.41 + time.sleep(options.duration) 1.42 + url = monitor.StopAndCollect(options.outfile) 1.43 + print 'View results in browser at %s' % url 1.44 + 1.45 +if __name__ == '__main__': 1.46 + sys.exit(main(sys.argv))