| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 """ | 3 """ |
| 4 Copyright 2014 Google Inc. | 4 Copyright 2014 Google Inc. |
| 5 | 5 |
| 6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
| 7 found in the LICENSE file. | 7 found in the LICENSE file. |
| 8 | 8 |
| 9 Compare GM results for two configs, across all builders. | 9 Compare GM results for two configs, across all builders. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 # System-level imports | 12 # System-level imports |
| 13 import argparse | 13 import argparse |
| 14 import fnmatch | 14 import fnmatch |
| 15 import json | 15 import json |
| 16 import logging | 16 import logging |
| 17 import os | |
| 18 import re | 17 import re |
| 19 import sys | |
| 20 import time | 18 import time |
| 21 | 19 |
| 22 # Imports from within Skia | 20 # Imports from within Skia |
| 23 # | 21 import fix_pythonpath # must do this first |
| 24 # TODO(epoger): Once we move the create_filepath_url() function out of | 22 from pyutils import url_utils |
| 25 # download_actuals into a shared utility module, we won't need to import | |
| 26 # download_actuals anymore. | |
| 27 # | |
| 28 # We need to add the 'gm' directory, so that we can import gm_json.py within | |
| 29 # that directory. That script allows us to parse the actual-results.json file | |
| 30 # written out by the GM tool. | |
| 31 # Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end* | |
| 32 # so any dirs that are already in the PYTHONPATH will be preferred. | |
| 33 PARENT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) | |
| 34 GM_DIRECTORY = os.path.dirname(PARENT_DIRECTORY) | |
| 35 TRUNK_DIRECTORY = os.path.dirname(GM_DIRECTORY) | |
| 36 if GM_DIRECTORY not in sys.path: | |
| 37 sys.path.append(GM_DIRECTORY) | |
| 38 import download_actuals | |
| 39 import gm_json | 23 import gm_json |
| 40 import imagediffdb | 24 import imagediffdb |
| 41 import imagepair | 25 import imagepair |
| 42 import imagepairset | 26 import imagepairset |
| 43 import results | 27 import results |
| 44 | 28 |
| 45 | 29 |
| 46 class ConfigComparisons(results.BaseComparisons): | 30 class ConfigComparisons(results.BaseComparisons): |
| 47 """Loads results from two different configurations into an ImagePairSet. | 31 """Loads results from two different configurations into an ImagePairSet. |
| 48 | 32 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 64 of generated_images_root | 48 of generated_images_root |
| 65 builder_regex_list: List of regular expressions specifying which builders | 49 builder_regex_list: List of regular expressions specifying which builders |
| 66 we will process. If None, process all builders. | 50 we will process. If None, process all builders. |
| 67 """ | 51 """ |
| 68 time_start = int(time.time()) | 52 time_start = int(time.time()) |
| 69 if builder_regex_list != None: | 53 if builder_regex_list != None: |
| 70 self.set_match_builders_pattern_list(builder_regex_list) | 54 self.set_match_builders_pattern_list(builder_regex_list) |
| 71 self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root) | 55 self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root) |
| 72 self._diff_base_url = ( | 56 self._diff_base_url = ( |
| 73 diff_base_url or | 57 diff_base_url or |
| 74 download_actuals.create_filepath_url(generated_images_root)) | 58 url_utils.create_filepath_url(generated_images_root)) |
| 75 self._actuals_root = actuals_root | 59 self._actuals_root = actuals_root |
| 76 self._load_config_pairs(configs) | 60 self._load_config_pairs(configs) |
| 77 self._timestamp = int(time.time()) | 61 self._timestamp = int(time.time()) |
| 78 logging.info('Results complete; took %d seconds.' % | 62 logging.info('Results complete; took %d seconds.' % |
| 79 (self._timestamp - time_start)) | 63 (self._timestamp - time_start)) |
| 80 | 64 |
| 81 def _load_config_pairs(self, configs): | 65 def _load_config_pairs(self, configs): |
| 82 """Loads the results of all tests, across all builders (based on the | 66 """Loads the results of all tests, across all builders (based on the |
| 83 files within self._actuals_root), compares them across two configs, | 67 files within self._actuals_root), compares them across two configs, |
| 84 and stores the summary in self._results. | 68 and stores the summary in self._results. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 results_obj = ConfigComparisons(configs=args.config, | 198 results_obj = ConfigComparisons(configs=args.config, |
| 215 actuals_root=args.actuals, | 199 actuals_root=args.actuals, |
| 216 generated_images_root=args.workdir) | 200 generated_images_root=args.workdir) |
| 217 gm_json.WriteToFile( | 201 gm_json.WriteToFile( |
| 218 results_obj.get_packaged_results_of_type(results_type=args.results), | 202 results_obj.get_packaged_results_of_type(results_type=args.results), |
| 219 args.outfile) | 203 args.outfile) |
| 220 | 204 |
| 221 | 205 |
| 222 if __name__ == '__main__': | 206 if __name__ == '__main__': |
| 223 main() | 207 main() |
| OLD | NEW |