| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 collections | 5 import collections |
| 6 | 6 |
| 7 from measurements import startup | 7 from measurements import startup |
| 8 from metrics import cpu | 8 from metrics import cpu |
| 9 from metrics import startup_metric | 9 from metrics import startup_metric |
| 10 from telemetry.core import util | 10 from telemetry.core import util |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 def RunNavigateSteps(self, page, tab): | 49 def RunNavigateSteps(self, page, tab): |
| 50 # Overriden so that no page navigation occurs. | 50 # Overriden so that no page navigation occurs. |
| 51 pass | 51 pass |
| 52 | 52 |
| 53 def ValidatePageSet(self, page_set): | 53 def ValidatePageSet(self, page_set): |
| 54 wpr_archive_names_to_page_urls = collections.defaultdict(list) | 54 wpr_archive_names_to_page_urls = collections.defaultdict(list) |
| 55 # Construct the map from pages' wpr archive names to pages' urls. | 55 # Construct the map from pages' wpr archive names to pages' urls. |
| 56 for page in page_set: | 56 for page in page_set: |
| 57 if page.is_local: | 57 if page.is_local: |
| 58 continue | 58 continue |
| 59 wpr_archive_name = page_set.WprFilePathForPage(page) | 59 wpr_archive_name = page_set.WprFilePathForUserStory(page) |
| 60 wpr_archive_names_to_page_urls[wpr_archive_name].append(page.url) | 60 wpr_archive_names_to_page_urls[wpr_archive_name].append(page.url) |
| 61 | 61 |
| 62 # Reject any pageset that contains more than one WPR archive. | 62 # Reject any pageset that contains more than one WPR archive. |
| 63 if len(wpr_archive_names_to_page_urls.keys()) > 1: | 63 if len(wpr_archive_names_to_page_urls.keys()) > 1: |
| 64 raise Exception("Invalid pageset: more than 1 WPR archive found.: " + | 64 raise Exception("Invalid pageset: more than 1 WPR archive found.: " + |
| 65 repr(wpr_archive_names_to_page_urls)) | 65 repr(wpr_archive_names_to_page_urls)) |
| 66 | 66 |
| 67 def DidStartBrowser(self, browser): | 67 def DidStartBrowser(self, browser): |
| 68 self._cpu_metric = cpu.CpuMetric(browser) | 68 self._cpu_metric = cpu.CpuMetric(browser) |
| 69 self._cpu_metric.Start(None, None) | 69 self._cpu_metric.Start(None, None) |
| 70 | 70 |
| 71 def ValidateAndMeasurePage(self, page, tab, results): | 71 def ValidateAndMeasurePage(self, page, tab, results): |
| 72 tab.WaitForDocumentReadyStateToBeComplete() | 72 tab.WaitForDocumentReadyStateToBeComplete() |
| 73 | 73 |
| 74 # Record CPU usage from browser start to when the foreground page is loaded. | 74 # Record CPU usage from browser start to when the foreground page is loaded. |
| 75 self._cpu_metric.Stop(None, None) | 75 self._cpu_metric.Stop(None, None) |
| 76 self._cpu_metric.AddResults(tab, results, 'cpu_utilization') | 76 self._cpu_metric.AddResults(tab, results, 'cpu_utilization') |
| 77 | 77 |
| 78 startup_metric.StartupMetric().AddResults(tab, results) | 78 startup_metric.StartupMetric().AddResults(tab, results) |
| 79 | 79 |
| 80 # TODO(jeremy): Measure time to load - first, last and frontmost tab here. | 80 # TODO(jeremy): Measure time to load - first, last and frontmost tab here. |
| OLD | NEW |