OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import collections | 7 import collections |
8 import json | 8 import json |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
11 import re | 11 import re |
12 import threading | 12 import threading |
13 import time | 13 import time |
14 import sys | 14 import sys |
15 | 15 |
16 from sets import Set | 16 from sets import Set |
17 from string import Template | 17 from string import Template |
18 | 18 |
19 sys.path.append(os.path.join(sys.path[0], os.pardir, os.pardir, os.pardir, | 19 sys.path.append(os.path.join(sys.path[0], os.pardir, os.pardir, os.pardir, |
20 'build','android')) | 20 'build','android')) |
21 from pylib import android_commands | |
22 from pylib import constants | 21 from pylib import constants |
| 22 from pylib.device import device_utils |
23 | 23 |
24 | 24 |
25 _ENTRIES = [ | 25 _ENTRIES = [ |
26 ('Total', '.* r... '), | 26 ('Total', '.* r... '), |
27 ('Read-only', '.* r--. '), | 27 ('Read-only', '.* r--. '), |
28 ('Read-write', '.* rw.. '), | 28 ('Read-write', '.* rw.. '), |
29 ('Executable', '.* ..x. '), | 29 ('Executable', '.* ..x. '), |
30 ('Anonymous total', '.* ""'), | 30 ('Anonymous total', '.* ""'), |
31 ('Anonymous read-write', '.* rw.. .* ""'), | 31 ('Anonymous read-write', '.* rw.. .* ""'), |
32 ('Anonymous executable (JIT\'ed code)', '.* ..x. .* ""'), | 32 ('Anonymous executable (JIT\'ed code)', '.* ..x. .* ""'), |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 all_pids[p] for p in pids | 198 all_pids[p] for p in pids |
199 ])) | 199 ])) |
200 print Template(_HTML_TEMPLATE).safe_substitute({ | 200 print Template(_HTML_TEMPLATE).safe_substitute({ |
201 'JSON_PIDS': json.dumps(pids), | 201 'JSON_PIDS': json.dumps(pids), |
202 'JSON_PIDS_INFO': json.dumps(pids_info) | 202 'JSON_PIDS_INFO': json.dumps(pids_info) |
203 }) | 203 }) |
204 | 204 |
205 | 205 |
206 | 206 |
207 def _CollectStats(count): | 207 def _CollectStats(count): |
208 adb = android_commands.AndroidCommands() | 208 device = device_utils.DeviceUtils() |
209 pid_list = adb.ExtractPid(package_name) | 209 pid_list = device.old_interface.ExtractPid(package_name) |
210 memdump = adb.RunShellCommand('/data/local/tmp/memdump ' + | 210 memdump = device.old_interface.RunShellCommand( |
211 ' '.join(pid_list)) | 211 '/data/local/tmp/memdump ' + ' '.join(pid_list)) |
212 process_stats = _CollectMemoryStats(memdump, | 212 process_stats = _CollectMemoryStats(memdump, |
213 [value for (key, value) in _ENTRIES]) | 213 [value for (key, value) in _ENTRIES]) |
214 for (pid, process) in zip(pid_list, process_stats): | 214 for (pid, process) in zip(pid_list, process_stats): |
215 first_pid_entry = True | 215 first_pid_entry = True |
216 for (k, v) in _ENTRIES: | 216 for (k, v) in _ENTRIES: |
217 if v not in process: | 217 if v not in process: |
218 continue | 218 continue |
219 for area_type in _AREA_TYPES: | 219 for area_type in _AREA_TYPES: |
220 legend = k + '_' + area_type | 220 legend = k + '_' + area_type |
221 if pid not in all_pids: | 221 if pid not in all_pids: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 type='int', | 269 type='int', |
270 help='Interval in seconds for manual collections.') | 270 help='Interval in seconds for manual collections.') |
271 options, args = parser.parse_args(argv) | 271 options, args = parser.parse_args(argv) |
272 if options.manual_graph: | 272 if options.manual_graph: |
273 return _RunManualGraph(options.package, options.interval) | 273 return _RunManualGraph(options.package, options.interval) |
274 _DumpCSV(_CollectMemoryStats(sys.stdin, [value for (key, value) in _ENTRIES])) | 274 _DumpCSV(_CollectMemoryStats(sys.stdin, [value for (key, value) in _ENTRIES])) |
275 | 275 |
276 | 276 |
277 if __name__ == '__main__': | 277 if __name__ == '__main__': |
278 main(sys.argv) | 278 main(sys.argv) |
OLD | NEW |