OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 csv | 5 import csv |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import shutil | 8 import shutil |
9 | 9 |
10 import chrome_cache | 10 import chrome_cache |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 in Task names (prefer names without spaces and special characters). | 94 in Task names (prefer names without spaces and special characters). |
95 transformer_list: An ordered list of function that takes an instance of | 95 transformer_list: An ordered list of function that takes an instance of |
96 SandwichRunner as parameter, would be applied immediately before | 96 SandwichRunner as parameter, would be applied immediately before |
97 SandwichRunner.Run() in the given order. | 97 SandwichRunner.Run() in the given order. |
98 | 98 |
99 Here is the full dependency of the added tree for the returned task: | 99 Here is the full dependency of the added tree for the returned task: |
100 <transformer_list_name>/{swr,worstcase}-metrics.csv | 100 <transformer_list_name>/{swr,worstcase}-metrics.csv |
101 depends on: <transformer_list_name>/{swr,worstcase}-run/ | 101 depends on: <transformer_list_name>/{swr,worstcase}-run/ |
102 depends on: some tasks saved by PopulateCommonPipelines() | 102 depends on: some tasks saved by PopulateCommonPipelines() |
103 """ | 103 """ |
104 ADDITIONAL_COLUMN_NAMES = [ | |
pasko
2016/05/31 16:00:00
I think we are not interested in publishing this v
pasko
2016/05/31 16:00:01
fits into one line. But if you want to separate it
gabadie
2016/06/01 12:04:34
Done.
gabadie
2016/06/01 12:04:34
Understood. But it is already not publishable sinc
pasko
2016/06/01 13:09:22
Ah, my bad, I thought it is a class constant. Our
gabadie
2016/06/01 13:32:16
I would still prefer additional_column_names becau
| |
105 'url', | |
106 'repeat_id'] | |
107 | |
104 task_prefix = os.path.join(transformer_list_name, '') | 108 task_prefix = os.path.join(transformer_list_name, '') |
105 if enable_swr: | 109 if enable_swr: |
106 task_prefix += 'swr' | 110 task_prefix += 'swr' |
107 else: | 111 else: |
108 task_prefix += 'worstcase' | 112 task_prefix += 'worstcase' |
109 | 113 |
110 @self.RegisterTask(task_prefix + '-run/', [self._patched_cache_task]) | 114 @self.RegisterTask(task_prefix + '-run/', [self._patched_cache_task]) |
111 def RunBenchmark(): | 115 def RunBenchmark(): |
112 runner = self._common_builder.CreateSandwichRunner() | 116 runner = self._common_builder.CreateSandwichRunner() |
113 for transformer in transformer_list: | 117 for transformer in transformer_list: |
114 transformer(runner) | 118 transformer(runner) |
115 runner.wpr_archive_path = self._common_builder.original_wpr_task.path | 119 runner.wpr_archive_path = self._common_builder.original_wpr_task.path |
116 runner.wpr_out_log_path = os.path.join( | 120 runner.wpr_out_log_path = os.path.join( |
117 RunBenchmark.path, sandwich_runner.WPR_LOG_FILENAME) | 121 RunBenchmark.path, sandwich_runner.WPR_LOG_FILENAME) |
118 runner.cache_archive_path = self._patched_cache_task.path | 122 runner.cache_archive_path = self._patched_cache_task.path |
119 runner.cache_operation = sandwich_runner.CacheOperation.PUSH | 123 runner.cache_operation = sandwich_runner.CacheOperation.PUSH |
120 runner.output_dir = RunBenchmark.path | 124 runner.output_dir = RunBenchmark.path |
121 if enable_swr: | 125 if enable_swr: |
122 runner.chrome_args.append('--enable-features=StaleWhileRevalidate2') | 126 runner.chrome_args.append('--enable-features=StaleWhileRevalidate2') |
123 runner.Run() | 127 runner.Run() |
124 | 128 |
125 @self.RegisterTask(task_prefix + '-metrics.csv', [RunBenchmark]) | 129 @self.RegisterTask(task_prefix + '-metrics.csv', [RunBenchmark]) |
126 def ExtractMetrics(): | 130 def ExtractMetrics(): |
127 trace_metrics_list = \ | 131 run_metrics_list = [] |
128 sandwich_metrics.ExtractMetricsFromRunnerOutputDirectory( | 132 for repeat_id, repeat_dir in sandwich_runner.WalkRepeatedRuns( |
129 None, RunBenchmark.path) | 133 RunBenchmark.path): |
130 trace_metrics_list.sort(key=lambda e: e['repeat_id']) | 134 trace_path = os.path.join(repeat_dir, sandwich_runner.TRACE_FILENAME) |
135 logging.info('processing trace \'%s\'' % trace_path) | |
pasko
2016/05/31 16:00:01
pylint wants it to be a comma, and quotes are not
gabadie
2016/06/01 12:04:34
Done.
| |
136 trace = loading_trace.LoadingTrace.FromJsonFile(trace_path) | |
137 run_metrics = { | |
138 'url': trace.url, | |
139 'repeat_id': repeat_id, | |
140 } | |
141 run_metrics.update( | |
142 sandwich_metrics.ExtractCommonMetricsFromRepeatDirectory( | |
143 repeat_dir, trace)) | |
144 run_metrics_list.append(run_metrics) | |
145 | |
146 run_metrics_list.sort(key=lambda e: e['repeat_id']) | |
pasko
2016/05/31 16:00:01
is sorting important in the CSV?
gabadie
2016/06/01 12:04:34
Yes to not depend on the underlying file system fi
| |
131 with open(ExtractMetrics.path, 'w') as csv_file: | 147 with open(ExtractMetrics.path, 'w') as csv_file: |
132 writer = csv.DictWriter(csv_file, | 148 writer = csv.DictWriter(csv_file, fieldnames=(ADDITIONAL_COLUMN_NAMES + |
133 fieldnames=sandwich_metrics.CSV_FIELD_NAMES) | 149 sandwich_metrics.COMMON_CSV_COLUMN_NAMES)) |
134 writer.writeheader() | 150 writer.writeheader() |
135 for trace_metrics in trace_metrics_list: | 151 for trace_metrics in run_metrics_list: |
136 writer.writerow(trace_metrics) | 152 writer.writerow(trace_metrics) |
137 | 153 |
138 self._common_builder.default_final_tasks.append(ExtractMetrics) | 154 self._common_builder.default_final_tasks.append(ExtractMetrics) |
OLD | NEW |