OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import collections |
| 6 |
| 7 from telemetry import multi_page_benchmark |
| 8 |
| 9 class LoadingBenchmark(multi_page_benchmark.MultiPageBenchmark): |
| 10 @property |
| 11 def results_are_the_same_on_every_page(self): |
| 12 return False |
| 13 |
| 14 def WillNavigateToPage(self, page, tab): |
| 15 tab.timeline.Start() |
| 16 |
| 17 def MeasurePage(self, page, tab, results): |
| 18 # In current telemetry tests, all tests wait for DocumentComplete state. |
| 19 # |
| 20 # TODO(nduca): when crbug.com/168431 is fixed, modify the page sets to |
| 21 # recognize loading as a toplevel action. |
| 22 tab.timeline.Stop() |
| 23 |
| 24 events = tab.timeline.timeline_model.GetAllEvents() |
| 25 |
| 26 events_by_name = collections.defaultdict(list) |
| 27 for e in events: |
| 28 events_by_name[e.name].append(e) |
| 29 |
| 30 for key, group in events_by_name.items(): |
| 31 times = [e.self_time_ms for e in group] |
| 32 total = sum(times) |
| 33 biggest_jank = max(times) |
| 34 results.Add(key, 'ms', total) |
| 35 results.Add(key + '_max', 'ms', biggest_jank) |
| 36 results.Add(key + '_avg', 'ms', total / len(times)) |
OLD | NEW |