| 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()
|
|
|