summaryrefslogtreecommitdiffstats
path: root/tools/android
diff options
context:
space:
mode:
authorskyostil@chromium.org <skyostil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-13 21:53:30 +0000
committerskyostil@chromium.org <skyostil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-13 21:53:30 +0000
commit3579f8fba28dc636dce1bb648574718d82bac3b8 (patch)
tree530f70d4ec2019760bf1061ba28c16ae86899367 /tools/android
parent59828d3af3f80d5d88c669f58a731a0283864d12 (diff)
downloadchromium_src-3579f8fba28dc636dce1bb648574718d82bac3b8.zip
chromium_src-3579f8fba28dc636dce1bb648574718d82bac3b8.tar.gz
chromium_src-3579f8fba28dc636dce1bb648574718d82bac3b8.tar.bz2
Make perf work in adb_profile_chrome when JSON converter isn't present
When the JSON converter isn't present, the user can still manually inspect perf recordings. BUG=375754 TEST=tools/android/adb_profile_chrome/run_tests Review URL: https://codereview.chromium.org/337543002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277095 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/android')
-rw-r--r--tools/android/adb_profile_chrome/perf_controller.py7
-rw-r--r--tools/android/adb_profile_chrome/perf_controller_unittest.py12
-rw-r--r--tools/android/adb_profile_chrome/profiler.py4
-rw-r--r--tools/android/adb_profile_chrome/ui.py2
4 files changed, 24 insertions, 1 deletions
diff --git a/tools/android/adb_profile_chrome/perf_controller.py b/tools/android/adb_profile_chrome/perf_controller.py
index 96a077d..064300d 100644
--- a/tools/android/adb_profile_chrome/perf_controller.py
+++ b/tools/android/adb_profile_chrome/perf_controller.py
@@ -182,5 +182,10 @@ class PerfProfilerController(controllers.BaseController):
open(json_file_name, 'w') as json_file:
cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i',
perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms]
- subprocess.call(cmd, stdout=json_file, stderr=dev_null)
+ if subprocess.call(cmd, stdout=json_file, stderr=dev_null):
+ logging.warning('Perf data to JSON conversion failed. The result will '
+ 'not contain any perf samples. You can still view the '
+ 'perf data manually as shown above.')
+ return None
+
return json_file_name
diff --git a/tools/android/adb_profile_chrome/perf_controller_unittest.py b/tools/android/adb_profile_chrome/perf_controller_unittest.py
index 381e441..eac12eba6 100644
--- a/tools/android/adb_profile_chrome/perf_controller_unittest.py
+++ b/tools/android/adb_profile_chrome/perf_controller_unittest.py
@@ -7,6 +7,9 @@ import json
from adb_profile_chrome import controllers_unittest
from adb_profile_chrome import perf_controller
+from adb_profile_chrome import ui
+
+from pylib import constants
class PerfProfilerControllerTest(controllers_unittest.BaseControllerTest):
@@ -20,6 +23,7 @@ class PerfProfilerControllerTest(controllers_unittest.BaseControllerTest):
def testTracing(self):
if not perf_controller.PerfProfilerController.IsSupported():
return
+ ui.EnableTestMode()
categories = ['cycles']
controller = perf_controller.PerfProfilerController(self.device,
categories)
@@ -31,6 +35,14 @@ class PerfProfilerControllerTest(controllers_unittest.BaseControllerTest):
controller.StopTracing()
result = controller.PullTrace()
+ # Perf-to-JSON conversion can fail if dependencies are missing.
+ if not result:
+ perf_script_path = os.path.join(constants.DIR_SOURCE_ROOT,
+ 'tools', 'telemetry', 'telemetry', 'core', 'platform', 'profiler',
+ 'perf_vis', 'perf_to_tracing.py')
+ assert not os.path.exists(perf_script_path)
+ return
+
try:
with open(result) as f:
json.loads(f.read())
diff --git a/tools/android/adb_profile_chrome/profiler.py b/tools/android/adb_profile_chrome/profiler.py
index 3480c60..b08dd3a 100644
--- a/tools/android/adb_profile_chrome/profiler.py
+++ b/tools/android/adb_profile_chrome/profiler.py
@@ -23,6 +23,10 @@ def _StopTracing(controllers):
def _PullTraces(controllers, output, compress, write_json):
ui.PrintMessage('Downloading...', eol='')
trace_files = [controller.PullTrace() for controller in controllers]
+ trace_files = [trace for trace in trace_files if trace]
+ if not trace_files:
+ ui.PrintMessage('No results')
+ return []
result = trace_packager.PackageTraces(trace_files,
output=output,
compress=compress,
diff --git a/tools/android/adb_profile_chrome/ui.py b/tools/android/adb_profile_chrome/ui.py
index 9913a43..bc95d48 100644
--- a/tools/android/adb_profile_chrome/ui.py
+++ b/tools/android/adb_profile_chrome/ui.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import logging
import select
import sys
@@ -23,3 +24,4 @@ def EnableTestMode():
global WaitForEnter
PrintMessage = NoOp
WaitForEnter = NoOp
+ logging.getLogger().disabled = True