OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 codecs | 5 import codecs |
6 import optparse | 6 import optparse |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 import time | 9 import time |
10 | 10 |
11 from py_utils import cloud_storage # pylint: disable=import-error | 11 from py_utils import cloud_storage # pylint: disable=import-error |
12 | 12 |
13 from telemetry.core import util | 13 from telemetry.core import util |
14 from telemetry.internal.results import chart_json_output_formatter | 14 from telemetry.internal.results import chart_json_output_formatter |
15 from telemetry.internal.results import csv_output_formatter | 15 from telemetry.internal.results import csv_output_formatter |
16 from telemetry.internal.results import csv_pivot_table_output_formatter | |
17 from telemetry.internal.results import gtest_progress_reporter | 16 from telemetry.internal.results import gtest_progress_reporter |
18 from telemetry.internal.results import histogram_set_json_output_formatter | 17 from telemetry.internal.results import histogram_set_json_output_formatter |
19 from telemetry.internal.results import html_output_formatter | 18 from telemetry.internal.results import html_output_formatter |
20 from telemetry.internal.results import json_3_output_formatter | 19 from telemetry.internal.results import json_3_output_formatter |
21 from telemetry.internal.results import json_output_formatter | 20 from telemetry.internal.results import json_output_formatter |
22 from telemetry.internal.results import legacy_html_output_formatter | 21 from telemetry.internal.results import legacy_html_output_formatter |
23 from telemetry.internal.results import page_test_results | 22 from telemetry.internal.results import page_test_results |
24 from telemetry.internal.results import progress_reporter | 23 from telemetry.internal.results import progress_reporter |
25 | 24 |
26 # Allowed output formats. The default is the first item in the list. | 25 # Allowed output formats. The default is the first item in the list. |
27 | 26 |
28 _OUTPUT_FORMAT_CHOICES = ( | 27 _OUTPUT_FORMAT_CHOICES = ( |
29 'chartjson', | 28 'chartjson', |
30 'csv', | 29 'csv', |
31 'csv-pivot-table', | |
32 'gtest', | 30 'gtest', |
33 'histograms', | 31 'histograms', |
34 'html', | 32 'html', |
35 'json', | 33 'json', |
36 'json-test-results', | 34 'json-test-results', |
37 'legacy-html', | 35 'legacy-html', |
38 'none', | 36 'none', |
39 ) | 37 ) |
40 | 38 |
41 _DEFAULT_OUTPUT_FORMAT = 'html' | 39 _DEFAULT_OUTPUT_FORMAT = 'html' |
42 | 40 |
43 | 41 |
44 # Filenames to use for given output formats. | 42 # Filenames to use for given output formats. |
45 _OUTPUT_FILENAME_LOOKUP = { | 43 _OUTPUT_FILENAME_LOOKUP = { |
46 'chartjson': 'results-chart.json', | 44 'chartjson': 'results-chart.json', |
47 'csv': 'results.csv', | 45 'csv': 'results.csv', |
48 'csv-pivot-table': 'results-pivot-table.csv', | |
49 'histograms': 'histograms.json', | 46 'histograms': 'histograms.json', |
50 'html': 'results.html', | 47 'html': 'results.html', |
51 'json': 'results.json', | 48 'json': 'results.json', |
52 'json-test-results': 'test-results.json', | 49 'json-test-results': 'test-results.json', |
53 'legacy-html': 'legacy-results.html' | 50 'legacy-html': 'legacy-results.html' |
54 } | 51 } |
55 | 52 |
56 | 53 |
57 def AddResultsOptions(parser): | 54 def AddResultsOptions(parser): |
58 group = optparse.OptionGroup(parser, 'Results options') | 55 group = optparse.OptionGroup(parser, 'Results options') |
(...skipping 12 matching lines...) Expand all Loading... |
71 default=None, | 68 default=None, |
72 help='Redirects output to a file. Defaults to stdout.') | 69 help='Redirects output to a file. Defaults to stdout.') |
73 group.add_option( | 70 group.add_option( |
74 '--output-dir', | 71 '--output-dir', |
75 default=util.GetBaseDir(), | 72 default=util.GetBaseDir(), |
76 help='Where to save output data after the run.') | 73 help='Where to save output data after the run.') |
77 group.add_option( | 74 group.add_option( |
78 '--output-trace-tag', | 75 '--output-trace-tag', |
79 default='', | 76 default='', |
80 help='Append a tag to the key of each result trace. Use ' | 77 help='Append a tag to the key of each result trace. Use ' |
81 'with html, csv-pivot-table output formats.') | 78 'with html output formats.') |
82 group.add_option( | 79 group.add_option( |
83 '--reset-results', action='store_true', help='Delete all stored results.') | 80 '--reset-results', action='store_true', help='Delete all stored results.') |
84 group.add_option( | 81 group.add_option( |
85 '--upload-results', | 82 '--upload-results', |
86 action='store_true', | 83 action='store_true', |
87 help='Upload the results to cloud storage.') | 84 help='Upload the results to cloud storage.') |
88 group.add_option( | 85 group.add_option( |
89 '--upload-bucket', | 86 '--upload-bucket', |
90 default='output', | 87 default='output', |
91 help='Storage bucket to use for the uploaded results. ' + | 88 help='Storage bucket to use for the uploaded results. ' + |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 upload_bucket = options.upload_bucket | 156 upload_bucket = options.upload_bucket |
160 if upload_bucket in cloud_storage.BUCKET_ALIASES: | 157 if upload_bucket in cloud_storage.BUCKET_ALIASES: |
161 upload_bucket = cloud_storage.BUCKET_ALIASES[upload_bucket] | 158 upload_bucket = cloud_storage.BUCKET_ALIASES[upload_bucket] |
162 | 159 |
163 output_formatters = [] | 160 output_formatters = [] |
164 for output_format in options.output_formats: | 161 for output_format in options.output_formats: |
165 if output_format == 'none' or output_format == "gtest": | 162 if output_format == 'none' or output_format == "gtest": |
166 continue | 163 continue |
167 | 164 |
168 output_stream = _GetOutputStream(output_format, options.output_dir) | 165 output_stream = _GetOutputStream(output_format, options.output_dir) |
169 if output_format == 'csv-pivot-table': | 166 if output_format == 'html': |
170 output_formatters.append( | |
171 csv_pivot_table_output_formatter.CsvPivotTableOutputFormatter( | |
172 output_stream, trace_tag=options.output_trace_tag)) | |
173 elif output_format == 'html': | |
174 output_formatters.append(html_output_formatter.HtmlOutputFormatter( | 167 output_formatters.append(html_output_formatter.HtmlOutputFormatter( |
175 output_stream, benchmark_metadata, options.reset_results, | 168 output_stream, benchmark_metadata, options.reset_results, |
176 upload_bucket)) | 169 upload_bucket)) |
177 elif output_format == 'json': | 170 elif output_format == 'json': |
178 output_formatters.append(json_output_formatter.JsonOutputFormatter( | 171 output_formatters.append(json_output_formatter.JsonOutputFormatter( |
179 output_stream, benchmark_metadata)) | 172 output_stream, benchmark_metadata)) |
180 elif output_format == 'json-test-results': | 173 elif output_format == 'json-test-results': |
181 output_formatters.append(json_3_output_formatter.JsonOutputFormatter( | 174 output_formatters.append(json_3_output_formatter.JsonOutputFormatter( |
182 output_stream)) | 175 output_stream)) |
183 elif output_format == 'chartjson': | 176 elif output_format == 'chartjson': |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 output_dir=options.output_dir, | 208 output_dir=options.output_dir, |
216 value_can_be_added_predicate=value_can_be_added_predicate, | 209 value_can_be_added_predicate=value_can_be_added_predicate, |
217 benchmark_enabled=benchmark_enabled) | 210 benchmark_enabled=benchmark_enabled) |
218 | 211 |
219 results.telemetry_info.benchmark_name = benchmark_metadata.name | 212 results.telemetry_info.benchmark_name = benchmark_metadata.name |
220 results.telemetry_info.benchmark_start_epoch = time.time() | 213 results.telemetry_info.benchmark_start_epoch = time.time() |
221 if options.results_label: | 214 if options.results_label: |
222 results.telemetry_info.label = options.results_label | 215 results.telemetry_info.label = options.results_label |
223 | 216 |
224 return results | 217 return results |
OLD | NEW |