| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import memory_expectations | 4 import memory_expectations |
| 5 import page_sets | 5 import page_sets |
| 6 | 6 |
| 7 from telemetry import benchmark | 7 from telemetry import benchmark |
| 8 from telemetry.page import page_test | 8 from telemetry.page import page_test |
| 9 from telemetry.timeline import counter | 9 from telemetry.timeline import counter |
| 10 from telemetry.timeline import model | 10 from telemetry.timeline import model |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 | 57 |
| 58 window.domAutomationController = domAutomationController; | 58 window.domAutomationController = domAutomationController; |
| 59 | 59 |
| 60 window.addEventListener("load", function() { | 60 window.addEventListener("load", function() { |
| 61 useGpuMemory(%d); | 61 useGpuMemory(%d); |
| 62 }, false); | 62 }, false); |
| 63 """ % MEMORY_LIMIT_MB | 63 """ % MEMORY_LIMIT_MB |
| 64 | 64 |
| 65 class _MemoryValidator(page_test.PageTest): | 65 class _MemoryValidator(page_test.PageTest): |
| 66 options = {'output_format': 'gtest'} |
| 67 |
| 66 def ValidatePage(self, page, tab, results): | 68 def ValidatePage(self, page, tab, results): |
| 67 timeline_data = tab.browser.StopTracing() | 69 timeline_data = tab.browser.StopTracing() |
| 68 timeline_model = model.TimelineModel(timeline_data) | 70 timeline_model = model.TimelineModel(timeline_data) |
| 69 for process in timeline_model.GetAllProcesses(): | 71 for process in timeline_model.GetAllProcesses(): |
| 70 if 'gpu.GpuMemoryUsage' in process.counters: | 72 if 'gpu.GpuMemoryUsage' in process.counters: |
| 71 counter = process.GetCounter('gpu', 'GpuMemoryUsage') | 73 counter = process.GetCounter('gpu', 'GpuMemoryUsage') |
| 72 mb_used = counter.samples[-1] / 1048576 | 74 mb_used = counter.samples[-1] / 1048576 |
| 73 | 75 |
| 74 if mb_used + WIGGLE_ROOM_MB < SINGLE_TAB_LIMIT_MB: | 76 if mb_used + WIGGLE_ROOM_MB < SINGLE_TAB_LIMIT_MB: |
| 75 raise page_test.Failure(self._FormatException('low', mb_used)) | 77 raise page_test.Failure(self._FormatException('low', mb_used)) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 98 page_set = page_sets.MemoryTestsPageSet | 100 page_set = page_sets.MemoryTestsPageSet |
| 99 | 101 |
| 100 def CreateExpectations(self, page_set): | 102 def CreateExpectations(self, page_set): |
| 101 return memory_expectations.MemoryExpectations() | 103 return memory_expectations.MemoryExpectations() |
| 102 | 104 |
| 103 def CreatePageSet(self, options): | 105 def CreatePageSet(self, options): |
| 104 page_set = super(Memory, self).CreatePageSet(options) | 106 page_set = super(Memory, self).CreatePageSet(options) |
| 105 for page in page_set.pages: | 107 for page in page_set.pages: |
| 106 page.script_to_evaluate_on_commit = test_harness_script | 108 page.script_to_evaluate_on_commit = test_harness_script |
| 107 return page_set | 109 return page_set |
| OLD | NEW |