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 from measurements import startup | 5 from measurements import startup |
6 from metrics import cpu | 6 from metrics import cpu |
7 from metrics import startup_metric | 7 from metrics import startup_metric |
8 | 8 |
9 | 9 |
10 class SessionRestore(startup.Startup): | 10 class SessionRestore(startup.Startup): |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 if len(wpr_archives.keys()) > 1: | 44 if len(wpr_archives.keys()) > 1: |
45 raise Exception("Invalid pageset: more than 1 WPR archive found.: " + | 45 raise Exception("Invalid pageset: more than 1 WPR archive found.: " + |
46 ', '.join(wpr_archives.keys())) | 46 ', '.join(wpr_archives.keys())) |
47 | 47 |
48 def DidStartBrowser(self, browser): | 48 def DidStartBrowser(self, browser): |
49 self._cpu_metric = cpu.CpuMetric(browser) | 49 self._cpu_metric = cpu.CpuMetric(browser) |
50 self._cpu_metric.Start(None, None) | 50 self._cpu_metric.Start(None, None) |
51 | 51 |
52 def MeasurePage(self, page, tab, results): | 52 def MeasurePage(self, page, tab, results): |
53 # Wait for all tabs to finish loading. | 53 # Wait for all tabs to finish loading. |
54 for i in xrange(len(tab.browser.tabs)): | 54 if 'android' in tab.browser.browser_type: |
tonyg
2014/02/12 22:25:57
I don't like defining the metric differently by pl
aberent
2014/02/13 11:37:43
Switched to Android behaviour in all cases. Switch
| |
55 t = tab.browser.tabs[i] | 55 # On android the background tabs are loaded on demand, so wont have been |
56 # loaded at this stage; so only wait for the foreground tab. Also | |
57 # document.hidden is broken on Android - crbug.com/322544 so assume this | |
58 # is tab[0] | |
59 t = tab.browser.tabs[0] | |
56 t.WaitForDocumentReadyStateToBeComplete() | 60 t.WaitForDocumentReadyStateToBeComplete() |
61 else: | |
62 for i in xrange(len(tab.browser.tabs)): | |
63 t = tab.browser.tabs[i] | |
64 t.WaitForDocumentReadyStateToBeComplete() | |
57 | 65 |
58 # Record CPU usage from browser start to when all pages have loaded. | 66 # Record CPU usage from browser start to when all pages have loaded. |
59 self._cpu_metric.Stop(None, None) | 67 self._cpu_metric.Stop(None, None) |
60 self._cpu_metric.AddResults(tab, results, 'cpu_utilization') | 68 self._cpu_metric.AddResults(tab, results, 'cpu_utilization') |
61 | 69 |
62 startup_metric.StartupMetric().AddResults(tab, results) | 70 startup_metric.StartupMetric().AddResults(tab, results) |
63 | 71 |
64 # TODO(jeremy): Measure time to load - first, last and frontmost tab here. | 72 # TODO(jeremy): Measure time to load - first, last and frontmost tab here. |
jeremy
2014/02/13 09:40:15
Can you leave this comment in when you make the ch
aberent
2014/02/13 11:37:43
Done.
| |
OLD | NEW |