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

Unified Diff: tools/telemetry/telemetry/core/platform/profiler/__init__.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
Index: tools/telemetry/telemetry/core/platform/profiler/__init__.py
diff --git a/tools/telemetry/telemetry/core/platform/profiler/__init__.py b/tools/telemetry/telemetry/core/platform/profiler/__init__.py
index 4fd39e16cd9a3cedb5a1b0a43655859bc35e8d26..f7b78c1ba430aa075691b7ee1953c1cd8ef398f2 100644
--- a/tools/telemetry/telemetry/core/platform/profiler/__init__.py
+++ b/tools/telemetry/telemetry/core/platform/profiler/__init__.py
@@ -2,11 +2,15 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import collections
+
class Profiler(object):
"""A sampling profiler provided by the platform."""
- def __init__(self, output_path):
- self.output_path = output_path
+ def __init__(self, browser_backend, platform_backend, output_path):
+ self._browser_backend = browser_backend
+ self._platform_backend = platform_backend
+ self._output_path = output_path
@classmethod
def name(cls):
@@ -18,6 +22,22 @@ class Profiler(object):
"""True iff this profiler is currently supported by the platform."""
raise NotImplementedError()
+ def _GetProcessOutputFileMap(self):
+ """Returns a dict with pid: output_file."""
+ all_pids = ([self._browser_backend.pid] +
+ self._platform_backend.GetChildPids(self._browser_backend.pid))
+
+ process_name_counts = collections.defaultdict(int)
+ process_output_file_map = {}
+ for pid in all_pids:
+ cmd_line = self._platform_backend.GetCommandLine(pid)
+ process_name = self._browser_backend.GetProcessName(cmd_line)
+ output_file = '%s.%s%s' % (self._output_path, process_name,
+ process_name_counts[process_name])
+ process_name_counts[process_name] += 1
+ process_output_file_map[pid] = output_file
+ return process_output_file_map
+
def CollectProfile(self):
"""Collect the profile from the profiler."""
raise NotImplementedError()
« no previous file with comments | « tools/telemetry/telemetry/core/browser.py ('k') | tools/telemetry/telemetry/core/platform/profiler/iprofiler_profiler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698