michael@0: # Copyright (c) 2012 The Chromium Authors. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: """Provides an interface to communicate with the device via the adb command. michael@0: michael@0: Assumes adb binary is currently on system path. michael@0: """ michael@0: michael@0: michael@0: import collections michael@0: michael@0: michael@0: def ParseIoStatsLine(line): michael@0: """Parses a line of io stats into a IoStats named tuple.""" michael@0: # Field definitions: http://www.kernel.org/doc/Documentation/iostats.txt michael@0: IoStats = collections.namedtuple('IoStats', michael@0: ['device', michael@0: 'num_reads_issued', michael@0: 'num_reads_merged', michael@0: 'num_sectors_read', michael@0: 'ms_spent_reading', michael@0: 'num_writes_completed', michael@0: 'num_writes_merged', michael@0: 'num_sectors_written', michael@0: 'ms_spent_writing', michael@0: 'num_ios_in_progress', michael@0: 'ms_spent_doing_io', michael@0: 'ms_spent_doing_io_weighted', michael@0: ]) michael@0: fields = line.split() michael@0: return IoStats._make([fields[2]] + [int(f) for f in fields[3:]])