OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Basic pyauto performance tests. | 6 """Basic pyauto performance tests. |
7 | 7 |
8 For tests that need to be run for multiple iterations (e.g., so that average | 8 For tests that need to be run for multiple iterations (e.g., so that average |
9 and standard deviation values can be reported), the default number of iterations | 9 and standard deviation values can be reported), the default number of iterations |
10 run for each of these tests is specified by |_DEFAULT_NUM_ITERATIONS|. | 10 run for each of these tests is specified by |_DEFAULT_NUM_ITERATIONS|. |
(...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2268 '--activate-on-launch', | 2268 '--activate-on-launch', |
2269 '--no-first-run', | 2269 '--no-first-run', |
2270 '--no-proxy-server', | 2270 '--no-proxy-server', |
2271 ] | 2271 ] |
2272 | 2272 |
2273 @classmethod | 2273 @classmethod |
2274 def Path(cls, key, **kwargs): | 2274 def Path(cls, key, **kwargs): |
2275 return FormatChromePath(cls._PATHS[key], **kwargs) | 2275 return FormatChromePath(cls._PATHS[key], **kwargs) |
2276 | 2276 |
2277 @classmethod | 2277 @classmethod |
2278 def ReplayServer(cls, test_name): | 2278 def ReplayServer(cls, test_name, replay_options=None): |
2279 archive_path = cls.Path('archive', test_name=test_name) | 2279 archive_path = cls.Path('archive', test_name=test_name) |
2280 return webpagereplay.ReplayServer(archive_path) | 2280 return webpagereplay.ReplayServer(archive_path, replay_options) |
2281 | 2281 |
2282 | 2282 |
2283 class PageCyclerNetSimTest(BasePageCyclerTest): | 2283 class PageCyclerNetSimTest(BasePageCyclerTest): |
2284 """Tests to run Web Page Replay backed page cycler tests.""" | 2284 """Tests to run Web Page Replay backed page cycler tests.""" |
2285 MAX_ITERATION_SECONDS = 180 | 2285 MAX_ITERATION_SECONDS = 180 |
2286 | 2286 |
2287 def ExtraChromeFlags(self): | 2287 def ExtraChromeFlags(self): |
2288 """Ensures Chrome is launched with custom flags. | 2288 """Ensures Chrome is launched with custom flags. |
2289 | 2289 |
2290 Returns: | 2290 Returns: |
(...skipping 12 matching lines...) Expand all Loading... |
2303 start_url += '&auto=1' | 2303 start_url += '&auto=1' |
2304 return start_url | 2304 return start_url |
2305 | 2305 |
2306 def RunPageCyclerTest(self, test_name, description): | 2306 def RunPageCyclerTest(self, test_name, description): |
2307 """Runs the specified PageCycler test. | 2307 """Runs the specified PageCycler test. |
2308 | 2308 |
2309 Args: | 2309 Args: |
2310 test_name: name for archive (.wpr) and config (.js) files. | 2310 test_name: name for archive (.wpr) and config (.js) files. |
2311 description: a string description for the test | 2311 description: a string description for the test |
2312 """ | 2312 """ |
2313 with PageCyclerReplay.ReplayServer(test_name) as replay_server: | 2313 replay_options = None |
2314 if replay_server.is_record_mode: | 2314 if self.IsMac(): |
| 2315 # Adding --net=fios uses dummynet by default (which Macs have). |
| 2316 # Linux would work after installing ipfw/dummynet and ipfw kernel module. |
| 2317 # Windows is trickier. It would require running WPR on a separate machine |
| 2318 # because running on same machine does not work with Windows loopback. |
| 2319 # Adding --no-admin-check skips running the entire script as sudo. |
| 2320 replay_options = ('--no-admin-check', '--net', 'fios') |
| 2321 with PageCyclerReplay.ReplayServer(test_name, replay_options) as server: |
| 2322 if server.is_record_mode: |
2315 self._num_iterations = 1 | 2323 self._num_iterations = 1 |
2316 super_self = super(PageCyclerNetSimTest, self) | 2324 super_self = super(PageCyclerNetSimTest, self) |
2317 super_self.RunPageCyclerTest(test_name, description) | 2325 super_self.RunPageCyclerTest(test_name, description) |
2318 | 2326 |
2319 def test2012Q2(self): | 2327 def test2012Q2(self): |
2320 self.RunPageCyclerTest('2012Q2', '2012Q2') | 2328 self.RunPageCyclerTest('2012Q2', '2012Q2') |
2321 | 2329 |
2322 | 2330 |
2323 class MemoryTest(BasePerfTest): | 2331 class MemoryTest(BasePerfTest): |
2324 """Tests to measure memory consumption under different usage scenarios.""" | 2332 """Tests to measure memory consumption under different usage scenarios.""" |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2653 """Identifies the port number to which the server is currently bound. | 2661 """Identifies the port number to which the server is currently bound. |
2654 | 2662 |
2655 Returns: | 2663 Returns: |
2656 The numeric port number to which the server is currently bound. | 2664 The numeric port number to which the server is currently bound. |
2657 """ | 2665 """ |
2658 return self._server.server_address[1] | 2666 return self._server.server_address[1] |
2659 | 2667 |
2660 | 2668 |
2661 if __name__ == '__main__': | 2669 if __name__ == '__main__': |
2662 pyauto_functional.Main() | 2670 pyauto_functional.Main() |
OLD | NEW |