1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
8 from telemetry.core import util
9 from telemetry.core.backends.chrome import android_browser_finder
10 from telemetry.core.platform import profiler
12 class AndroidMemReportProfiler(profiler.Profiler):
13 """Android-specific, collects 'memreport' graphs."""
15 def __init__(self, browser_backend, platform_backend, output_path, state):
16 super(AndroidMemReportProfiler, self).__init__(
17 browser_backend, platform_backend, output_path, state)
18 self._html_file = output_path + '.html'
19 self._memreport = subprocess.Popen(
20 [os.path.join(util.GetChromiumSrcDir(),
21 'tools', 'android', 'memdump', 'memreport.py'),
22 '--manual-graph', '--package', browser_backend.package],
23 stdout=file(self._html_file, 'w'),
24 stdin=subprocess.PIPE)
28 return 'android-memreport'
31 def is_supported(cls, browser_type):
32 if browser_type == 'any':
33 return android_browser_finder.CanFindAvailableBrowsers()
34 return browser_type.startswith('android')
36 def CollectProfile(self):
37 self._memreport.communicate(input='\n')
38 self._memreport.wait()
39 print 'To view the memory report, open:'
41 return [self._html_file]