| 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 os | 5 import os |
| 6 import json | 6 import json |
| 7 | 7 |
| 8 from adb_profile_chrome import controllers_unittest | 8 from adb_profile_chrome import controllers_unittest |
| 9 from adb_profile_chrome import perf_controller | 9 from adb_profile_chrome import perf_controller |
| 10 from adb_profile_chrome import ui | 10 from adb_profile_chrome import ui |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 controller = perf_controller.PerfProfilerController(self.device, | 28 controller = perf_controller.PerfProfilerController(self.device, |
| 29 categories) | 29 categories) |
| 30 | 30 |
| 31 interval = 1 | 31 interval = 1 |
| 32 try: | 32 try: |
| 33 controller.StartTracing(interval) | 33 controller.StartTracing(interval) |
| 34 finally: | 34 finally: |
| 35 controller.StopTracing() | 35 controller.StopTracing() |
| 36 | 36 |
| 37 result = controller.PullTrace() | 37 result = controller.PullTrace() |
| 38 # Perf-to-JSON conversion can fail if dependencies are missing. | |
| 39 if not result: | |
| 40 perf_script_path = os.path.join(constants.DIR_SOURCE_ROOT, | |
| 41 'tools', 'telemetry', 'telemetry', 'core', 'platform', 'profiler', | |
| 42 'perf_vis', 'perf_to_tracing.py') | |
| 43 assert not os.path.exists(perf_script_path) | |
| 44 return | |
| 45 | |
| 46 try: | 38 try: |
| 47 with open(result) as f: | 39 with open(result) as f: |
| 48 json.loads(f.read()) | 40 json.loads(f.read()) |
| 49 finally: | 41 finally: |
| 50 os.remove(result) | 42 os.remove(result) |
| OLD | NEW |