| OLD | NEW |
| 1 # Copyright (C) 2011, Google Inc. All rights reserved. | 1 # Copyright (C) 2011, Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 import copy | 29 import copy |
| 30 import logging | 30 import logging |
| 31 import functools | 31 import functools |
| 32 | 32 |
| 33 from webkitpy.common.memoized import memoized | 33 from webkitpy.common.memoized import memoized |
| 34 | 34 |
| 35 _log = logging.getLogger(__name__) | 35 _log = logging.getLogger(__name__) |
| 36 | 36 |
| 37 | 37 |
| 38 # FIXME: Should this function be somewhere more general? | |
| 39 def _invert_dictionary(dictionary): | |
| 40 inverted_dictionary = {} | |
| 41 for key, value in dictionary.items(): | |
| 42 if inverted_dictionary.get(value): | |
| 43 inverted_dictionary[value].append(key) | |
| 44 else: | |
| 45 inverted_dictionary[value] = [key] | |
| 46 return inverted_dictionary | |
| 47 | |
| 48 | |
| 49 class BaselineOptimizer(object): | 38 class BaselineOptimizer(object): |
| 50 ROOT_LAYOUT_TESTS_DIRECTORY = 'LayoutTests' | 39 ROOT_LAYOUT_TESTS_DIRECTORY = 'LayoutTests' |
| 51 | 40 |
| 52 def __init__(self, host, port, port_names): | 41 def __init__(self, host, port, port_names): |
| 53 self._filesystem = host.filesystem | 42 self._filesystem = host.filesystem |
| 54 self._default_port = port | 43 self._default_port = port |
| 55 self._ports = {} | 44 self._ports = {} |
| 56 for port_name in port_names: | 45 for port_name in port_names: |
| 57 self._ports[port_name] = host.port_factory.get(port_name) | 46 self._ports[port_name] = host.port_factory.get(port_name) |
| 58 | 47 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 result = self._optimize_subtree(baseline_name) | 308 result = self._optimize_subtree(baseline_name) |
| 320 non_virtual_baseline_name = self._virtual_base(baseline_name) | 309 non_virtual_baseline_name = self._virtual_base(baseline_name) |
| 321 if not non_virtual_baseline_name: | 310 if not non_virtual_baseline_name: |
| 322 return result | 311 return result |
| 323 | 312 |
| 324 self._optimize_virtual_root(baseline_name, non_virtual_baseline_name) | 313 self._optimize_virtual_root(baseline_name, non_virtual_baseline_name) |
| 325 | 314 |
| 326 _log.debug("Optimizing non-virtual fallback path.") | 315 _log.debug("Optimizing non-virtual fallback path.") |
| 327 result |= self._optimize_subtree(non_virtual_baseline_name) | 316 result |= self._optimize_subtree(non_virtual_baseline_name) |
| 328 return result | 317 return result |
| OLD | NEW |