Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: tools/telemetry/telemetry/core/platform/profiler/sample_profiler.py

Issue 14978006: Telemetry: makes profilers a bit more generic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dict / member name Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/platform/profiler/perf_profiler.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/platform/profiler/sample_profiler.py
diff --git a/tools/telemetry/telemetry/core/platform/profiler/sample_profiler.py b/tools/telemetry/telemetry/core/platform/profiler/sample_profiler.py
index 608b59d2b718db7cbfa2e62cfdfd603131eb2425..c8fd866f40ef9cfd8221095c2792a973969b5695 100644
--- a/tools/telemetry/telemetry/core/platform/profiler/sample_profiler.py
+++ b/tools/telemetry/telemetry/core/platform/profiler/sample_profiler.py
@@ -11,29 +11,18 @@ from telemetry.core import util
from telemetry.core.platform import profiler
-class SampleProfiler(profiler.Profiler):
-
- def __init__(self, browser_backend, pid, output_path):
- super(SampleProfiler, self).__init__(output_path)
- self._browser_backend = browser_backend
+class _SingleProcessSampleProfiler(object):
+ """An internal class for using iprofiler for a given process."""
+ def __init__(self, pid, output_path):
+ self._output_path = output_path
self._tmp_output_file = tempfile.NamedTemporaryFile('w', 0)
self._proc = subprocess.Popen(
- ['sample', str(pid), '-mayDie', '-file', self.output_path],
+ ['sample', str(pid), '-mayDie', '-file', self._output_path],
stdout=self._tmp_output_file, stderr=subprocess.STDOUT)
def IsStarted():
return 'Sampling process' in self._GetStdOut()
util.WaitFor(IsStarted, 120)
- @classmethod
- def name(cls):
- return 'sample'
-
- @classmethod
- def is_supported(cls, options):
- return (sys.platform == 'darwin'
- and not options.browser_type.startswith('android')
- and not options.browser_type.startswith('cros'))
-
def CollectProfile(self):
self._proc.send_signal(signal.SIGINT)
exit_code = self._proc.wait()
@@ -47,7 +36,7 @@ class SampleProfiler(profiler.Profiler):
self._tmp_output_file.close()
print 'To view the profile, run:'
- print ' open -a TextEdit %s' % self.output_path
+ print ' open -a TextEdit %s' % self._output_path
def _GetStdOut(self):
self._tmp_output_file.flush()
@@ -56,3 +45,29 @@ class SampleProfiler(profiler.Profiler):
return f.read()
except IOError:
return ''
+
+
+class SampleProfiler(profiler.Profiler):
+
+ def __init__(self, browser_backend, platform_backend, output_path):
+ super(SampleProfiler, self).__init__(
+ browser_backend, platform_backend, output_path)
+ process_output_file_map = self._GetProcessOutputFileMap()
+ self._process_profilers = []
+ for pid, output_file in process_output_file_map.iteritems():
+ self._process_profilers.append(
+ _SingleProcessSampleProfiler(pid, output_file))
+
+ @classmethod
+ def name(cls):
+ return 'sample'
+
+ @classmethod
+ def is_supported(cls, options):
+ return (sys.platform == 'darwin'
+ and not options.browser_type.startswith('android')
+ and not options.browser_type.startswith('cros'))
+
+ def CollectProfile(self):
+ for single_process in self._process_profilers:
+ single_process.CollectProfile()
« no previous file with comments | « tools/telemetry/telemetry/core/platform/profiler/perf_profiler.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698