| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 import time | 9 import time |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 # Constants for all tests in this suite. | 33 # Constants for all tests in this suite. |
| 34 NUM_SECONDS_BETWEEN_MEASUREMENTS = 10 | 34 NUM_SECONDS_BETWEEN_MEASUREMENTS = 10 |
| 35 MEASUREMENT_LOG_MESSAGE_TEMPLATE = '[%s] %.2f MB (pid: %d)' | 35 MEASUREMENT_LOG_MESSAGE_TEMPLATE = '[%s] %.2f MB (pid: %d)' |
| 36 LOG_TO_OUTPUT_FILE = True | 36 LOG_TO_OUTPUT_FILE = True |
| 37 | 37 |
| 38 # Constants for testTabRendererProcessMemoryUsage. | 38 # Constants for testTabRendererProcessMemoryUsage. |
| 39 RENDERER_PROCESS_URL = 'http://chrome.angrybirds.com' | 39 RENDERER_PROCESS_URL = 'http://chrome.angrybirds.com' |
| 40 RENDERER_PROCESS_OUTPUT_FILE = 'renderer_process_mem.txt' | 40 RENDERER_PROCESS_OUTPUT_FILE = 'renderer_process_mem.txt' |
| 41 | 41 |
| 42 # Constants for testExtensionProcessMemoryUsage. | 42 # Constants for testExtensionProcessMemoryUsage. |
| 43 EXTENSION_LOCATION = pyauto.FilePath( | 43 EXTENSION_LOCATION = os.path.abspath(os.path.join( |
| 44 os.path.abspath(os.path.join(pyauto.PyUITest.DataDir(), 'extensions', | 44 pyauto.PyUITest.DataDir(), 'extensions', 'google_talk.crx')) |
| 45 'google_talk.crx'))) | |
| 46 EXTENSION_PROCESS_NAME = 'Google Talk' | 45 EXTENSION_PROCESS_NAME = 'Google Talk' |
| 47 EXTENSION_PROCESS_OUTPUT_FILE = 'extension_process_mem.txt' | 46 EXTENSION_PROCESS_OUTPUT_FILE = 'extension_process_mem.txt' |
| 48 | 47 |
| 49 def _GetPidOfExtensionProcessByName(self, name): | 48 def _GetPidOfExtensionProcessByName(self, name): |
| 50 """Identifies the process ID of an extension process, given its name. | 49 """Identifies the process ID of an extension process, given its name. |
| 51 | 50 |
| 52 Args: | 51 Args: |
| 53 name: The string name of an extension process, as returned by the function | 52 name: The string name of an extension process, as returned by the function |
| 54 GetBrowserInfo(). | 53 GetBrowserInfo(). |
| 55 | 54 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 usage = test_utils.GetMemoryUsageOfProcess(pid) | 126 usage = test_utils.GetMemoryUsageOfProcess(pid) |
| 128 current_time = time.asctime(time.localtime(time.time())) | 127 current_time = time.asctime(time.localtime(time.time())) |
| 129 self._LogMessage( | 128 self._LogMessage( |
| 130 self.EXTENSION_PROCESS_OUTPUT_FILE, | 129 self.EXTENSION_PROCESS_OUTPUT_FILE, |
| 131 self.MEASUREMENT_LOG_MESSAGE_TEMPLATE % (current_time, usage, pid)) | 130 self.MEASUREMENT_LOG_MESSAGE_TEMPLATE % (current_time, usage, pid)) |
| 132 time.sleep(self.NUM_SECONDS_BETWEEN_MEASUREMENTS) | 131 time.sleep(self.NUM_SECONDS_BETWEEN_MEASUREMENTS) |
| 133 | 132 |
| 134 | 133 |
| 135 if __name__ == '__main__': | 134 if __name__ == '__main__': |
| 136 pyauto_functional.Main() | 135 pyauto_functional.Main() |
| OLD | NEW |