OLD | NEW |
| (Empty) |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 from metrics import Metric | |
6 | |
7 class IOMetric(Metric): | |
8 """IO-related metrics, obtained via telemetry.core.Browser.""" | |
9 | |
10 @classmethod | |
11 def CustomizeBrowserOptions(cls, options): | |
12 options.AppendExtraBrowserArgs('--no-sandbox') | |
13 | |
14 def Start(self, page, tab): | |
15 raise NotImplementedError() | |
16 | |
17 def Stop(self, page, tab): | |
18 raise NotImplementedError() | |
19 | |
20 def AddResults(self, tab, results): | |
21 # This metric currently only returns summary results, not per-page results. | |
22 raise NotImplementedError() | |
23 | |
24 def AddSummaryResults(self, browser, results): | |
25 """Add summary results to the results object.""" | |
26 io_stats = browser.io_stats | |
27 if not io_stats['Browser']: | |
28 return | |
29 | |
30 def AddSummariesForProcessType(process_type_io, process_type_trace): | |
31 """For a given process type, add all relevant summary results. | |
32 | |
33 Args: | |
34 process_type_io: Type of process (eg Browser or Renderer). | |
35 process_type_trace: String to be added to the trace name in the results. | |
36 """ | |
37 if 'ReadOperationCount' in io_stats[process_type_io]: | |
38 results.AddSummary('read_operations_' + process_type_trace, 'count', | |
39 io_stats[process_type_io] | |
40 ['ReadOperationCount'], | |
41 data_type='unimportant') | |
42 if 'WriteOperationCount' in io_stats[process_type_io]: | |
43 results.AddSummary('write_operations_' + process_type_trace, 'count', | |
44 io_stats[process_type_io] | |
45 ['WriteOperationCount'], | |
46 data_type='unimportant') | |
47 if 'ReadTransferCount' in io_stats[process_type_io]: | |
48 results.AddSummary('read_bytes_' + process_type_trace, 'kb', | |
49 io_stats[process_type_io] | |
50 ['ReadTransferCount'] / 1024, | |
51 data_type='unimportant') | |
52 if 'WriteTransferCount' in io_stats[process_type_io]: | |
53 results.AddSummary('write_bytes_' + process_type_trace, 'kb', | |
54 io_stats[process_type_io] | |
55 ['WriteTransferCount'] / 1024, | |
56 data_type='unimportant') | |
57 | |
58 AddSummariesForProcessType('Browser', 'browser') | |
59 AddSummariesForProcessType('Renderer', 'renderer') | |
60 AddSummariesForProcessType('Gpu', 'gpu') | |
61 | |
OLD | NEW |