| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 import time | 8 import time |
| 9 | 9 |
| 10 from profile_chrome import controllers | 10 from profile_chrome import controllers |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 def GetCategories(device, package_info): | 40 def GetCategories(device, package_info): |
| 41 device.BroadcastIntent(intent.Intent( | 41 device.BroadcastIntent(intent.Intent( |
| 42 action='%s.GPU_PROFILER_LIST_CATEGORIES' % package_info.package)) | 42 action='%s.GPU_PROFILER_LIST_CATEGORIES' % package_info.package)) |
| 43 try: | 43 try: |
| 44 json_category_list = device.old_interface.WaitForLogMatch( | 44 json_category_list = device.old_interface.WaitForLogMatch( |
| 45 re.compile(r'{"traceCategoriesList(.*)'), None, timeout=5).group(0) | 45 re.compile(r'{"traceCategoriesList(.*)'), None, timeout=5).group(0) |
| 46 except pexpect.TIMEOUT: | 46 except pexpect.TIMEOUT: |
| 47 raise RuntimeError('Performance trace category list marker not found. ' | 47 raise RuntimeError('Performance trace category list marker not found. ' |
| 48 'Is the correct version of the browser running?') | 48 'Is the correct version of the browser running?') |
| 49 | 49 |
| 50 record_categories = [] | 50 record_categories = set() |
| 51 disabled_by_default_categories = [] | 51 disabled_by_default_categories = set() |
| 52 json_data = json.loads(json_category_list)['traceCategoriesList'] | 52 json_data = json.loads(json_category_list)['traceCategoriesList'] |
| 53 for item in json_data: | 53 for item in json_data: |
| 54 if item.startswith('disabled-by-default'): | 54 for category in item.split(','): |
| 55 disabled_by_default_categories.append(item) | 55 if category.startswith('disabled-by-default'): |
| 56 else: | 56 disabled_by_default_categories.add(category) |
| 57 record_categories.append(item) | 57 else: |
| 58 record_categories.add(category) |
| 58 | 59 |
| 59 return record_categories, disabled_by_default_categories | 60 return list(record_categories), list(disabled_by_default_categories) |
| 60 | 61 |
| 61 def StartTracing(self, interval): | 62 def StartTracing(self, interval): |
| 62 self._trace_interval = interval | 63 self._trace_interval = interval |
| 63 self._device.old_interface.SyncLogCat() | 64 self._device.old_interface.SyncLogCat() |
| 64 start_extras = {'categories': ','.join(self._categories)} | 65 start_extras = {'categories': ','.join(self._categories)} |
| 65 if self._ring_buffer: | 66 if self._ring_buffer: |
| 66 start_extras['continuous'] = None | 67 start_extras['continuous'] = None |
| 67 self._device.BroadcastIntent(intent.Intent( | 68 self._device.BroadcastIntent(intent.Intent( |
| 68 action='%s.GPU_PROFILER_START' % self._package_info.package, | 69 action='%s.GPU_PROFILER_START' % self._package_info.package, |
| 69 extras=start_extras)) | 70 extras=start_extras)) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 98 self._device.SetProp(_HEAP_PROFILE_MMAP_PROPERTY, 0) | 99 self._device.SetProp(_HEAP_PROFILE_MMAP_PROPERTY, 0) |
| 99 | 100 |
| 100 def PullTrace(self): | 101 def PullTrace(self): |
| 101 # Wait a bit for the browser to finish writing the trace file. | 102 # Wait a bit for the browser to finish writing the trace file. |
| 102 time.sleep(self._trace_interval / 4 + 1) | 103 time.sleep(self._trace_interval / 4 + 1) |
| 103 | 104 |
| 104 trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/') | 105 trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/') |
| 105 host_file = os.path.join(os.path.curdir, os.path.basename(trace_file)) | 106 host_file = os.path.join(os.path.curdir, os.path.basename(trace_file)) |
| 106 self._device.PullFile(trace_file, host_file) | 107 self._device.PullFile(trace_file, host_file) |
| 107 return host_file | 108 return host_file |
| OLD | NEW |