| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import glob | 5 import glob |
| 6 import os | 6 import os |
| 7 import subprocess | 7 import subprocess |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 from telemetry.internal.platform import profiler | 10 from telemetry.internal.platform import profiler |
| 11 | 11 |
| 12 _PGOSWEEP_EXECUTABLE = 'pgosweep.exe' | 12 _PGOSWEEP_EXECUTABLE = 'pgosweep.exe' |
| 13 | 13 |
| 14 | 14 |
| 15 class WinPGOProfiler(profiler.Profiler): | 15 class WinPGOProfiler(profiler.Profiler): |
| 16 """A profiler that run the Visual Studio PGO utility 'pgosweep.exe' before | 16 """A profiler that run the Visual Studio PGO utility 'pgosweep.exe' before |
| 17 terminating a browser or a renderer process. | 17 terminating a browser or a renderer process. |
| 18 |
| 19 TODO(sebmarchand): Stop relying on Telemetry to do this, move this logic to |
| 20 Chrome. |
| 18 """ | 21 """ |
| 19 | 22 |
| 20 def __init__(self, browser_backend, platform_backend, output_path, state): | 23 def __init__(self, browser_backend, platform_backend, output_path, state): |
| 21 super(WinPGOProfiler, self).__init__( | 24 super(WinPGOProfiler, self).__init__( |
| 22 browser_backend, platform_backend, output_path, state) | 25 browser_backend, platform_backend, output_path, state) |
| 23 | 26 |
| 24 self._pgosweep_path = None | 27 self._pgosweep_path = None |
| 25 | 28 |
| 26 if os.path.exists(os.path.join(browser_backend.browser_directory, | 29 if os.path.exists(os.path.join(browser_backend.browser_directory, |
| 27 _PGOSWEEP_EXECUTABLE)): | 30 _PGOSWEEP_EXECUTABLE)): |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 def is_supported(cls, browser_type): | 85 def is_supported(cls, browser_type): |
| 83 # This profiler only make sense when doing a Windows build with Visual | 86 # This profiler only make sense when doing a Windows build with Visual |
| 84 # Studio (minimal supported version is 2013 Update 2). | 87 # Studio (minimal supported version is 2013 Update 2). |
| 85 return sys.platform.startswith('win') | 88 return sys.platform.startswith('win') |
| 86 | 89 |
| 87 @classmethod | 90 @classmethod |
| 88 def CustomizeBrowserOptions(cls, browser_type, options): | 91 def CustomizeBrowserOptions(cls, browser_type, options): |
| 89 # The sandbox need to be disabled if we want to be able to gather the | 92 # The sandbox need to be disabled if we want to be able to gather the |
| 90 # profile data. | 93 # profile data. |
| 91 options.AppendExtraBrowserArgs('--no-sandbox') | 94 options.AppendExtraBrowserArgs('--no-sandbox') |
| 95 # Augment the startup timeout as a PGO instrumented build takes more time to |
| 96 # start than a regular build. |
| 97 options.browser_options.browser_startup_timeout *= 4 |
| 92 | 98 |
| 93 def CollectProfile(self): | 99 def CollectProfile(self): |
| 94 """Collect the profile data for the current processes.""" | 100 """Collect the profile data for the current processes.""" |
| 95 output_files = [] | 101 output_files = [] |
| 96 for pid, output_file in self._GetProcessOutputFileMap().iteritems(): | 102 for pid, output_file in self._GetProcessOutputFileMap().iteritems(): |
| 97 if 'renderer' in output_file: | 103 if 'renderer' in output_file: |
| 98 output_files.append(self._RunPGOSweep(pid, | 104 output_files.append(self._RunPGOSweep(pid, |
| 99 'chrome_child', | 105 'chrome_child', |
| 100 self._chrome_child_pgc_counter)) | 106 self._chrome_child_pgc_counter)) |
| 101 self._chrome_child_pgc_counter += 1 | 107 self._chrome_child_pgc_counter += 1 |
| 102 return output_files | 108 return output_files |
| OLD | NEW |