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 from telemetry import page_test | 4 from telemetry.page import page_test |
5 | 5 |
6 class MeasurementFailure(page_test.Failure): | 6 class MeasurementFailure(page_test.Failure): |
7 """Exception that can be thrown from MeasurePage to indicate an undesired but | 7 """Exception that can be thrown from MeasurePage to indicate an undesired but |
8 designed-for problem.""" | 8 designed-for problem.""" |
9 pass | 9 pass |
10 | 10 |
11 # TODO(nduca): Rename to page_benchmark | 11 # TODO(nduca): Rename to page_benchmark |
12 class MultiPageBenchmark(page_test.PageTest): | 12 class MultiPageBenchmark(page_test.PageTest): |
13 """Glue code for running a benchmark across a set of pages. | 13 """Glue code for running a benchmark across a set of pages. |
14 | 14 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 benchmark discovers what values it can report as it goes, and those values | 59 benchmark discovers what values it can report as it goes, and those values |
60 may vary from page to page, you need to override this function and return | 60 may vary from page to page, you need to override this function and return |
61 False. Output will not appear in this mode until the entire pageset has | 61 False. Output will not appear in this mode until the entire pageset has |
62 run.""" | 62 run.""" |
63 return True | 63 return True |
64 | 64 |
65 def MeasurePage(self, page, tab, results): | 65 def MeasurePage(self, page, tab, results): |
66 """Override to actually measure the page's performance. | 66 """Override to actually measure the page's performance. |
67 | 67 |
68 page is a page_set.Page | 68 page is a page_set.Page |
69 tab is an instance of telemetry.Tab | 69 tab is an instance of telemetry.core.Tab |
70 | 70 |
71 Should call results.Add(name, units, value) for each result, or raise an | 71 Should call results.Add(name, units, value) for each result, or raise an |
72 exception on failure. The name and units of each Add() call must be | 72 exception on failure. The name and units of each Add() call must be |
73 the same across all iterations. The name 'url' must not be used. | 73 the same across all iterations. The name 'url' must not be used. |
74 | 74 |
75 Prefer field names that are in accordance with python variable style. E.g. | 75 Prefer field names that are in accordance with python variable style. E.g. |
76 field_name. | 76 field_name. |
77 | 77 |
78 Put together: | 78 Put together: |
79 | 79 |
80 def MeasurePage(self, page, tab, results): | 80 def MeasurePage(self, page, tab, results): |
81 res = tab.EvaluateJavaScript('2+2') | 81 res = tab.EvaluateJavaScript('2+2') |
82 if res != 4: | 82 if res != 4: |
83 raise Exception('Oh, wow.') | 83 raise Exception('Oh, wow.') |
84 results.Add('two_plus_two', 'count', res) | 84 results.Add('two_plus_two', 'count', res) |
85 """ | 85 """ |
86 raise NotImplementedError() | 86 raise NotImplementedError() |
OLD | NEW |