Shave 0.5 seconds off check-webkit-style runtime for test_expectations.txt
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jan 2012 23:14:56 +0000 (23:14 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jan 2012 23:14:56 +0000 (23:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76576

Reviewed by Adam Barth.

Avoid calling default_configuration in base.py. We don't need it for
checking test_expectations.txt style. It takes ~0.5 seconds to run on my
Mac Pro. It's the call to "perl Tools/Scripts/webkit-build-directory --top-level"
from common.executive.

At some point someone should probably look into why that call is so slow
since it's on the critical path for run-webkit-tests and build-webkit startup.

* Scripts/webkitpy/layout_tests/port/base.py:
(Port.__init__):
* Scripts/webkitpy/style/checkers/test_expectations.py:
(TestExpectationsChecker._determine_port_from_exepectations_path):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105332 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/port/base.py
Tools/Scripts/webkitpy/style/checkers/test_expectations.py

index 3a66177..213fd46 100644 (file)
@@ -1,3 +1,23 @@
+2012-01-18  Ojan Vafai  <ojan@chromium.org>
+
+        Shave 0.5 seconds off check-webkit-style runtime for test_expectations.txt
+        https://bugs.webkit.org/show_bug.cgi?id=76576
+
+        Reviewed by Adam Barth.
+
+        Avoid calling default_configuration in base.py. We don't need it for
+        checking test_expectations.txt style. It takes ~0.5 seconds to run on my
+        Mac Pro. It's the call to "perl Tools/Scripts/webkit-build-directory --top-level"
+        from common.executive.
+
+        At some point someone should probably look into why that call is so slow
+        since it's on the critical path for run-webkit-tests and build-webkit startup.
+
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        (Port.__init__):
+        * Scripts/webkitpy/style/checkers/test_expectations.py:
+        (TestExpectationsChecker._determine_port_from_exepectations_path):
+
 2012-01-18  Dirk Pranke  <dpranke@chromium.org>
 
         [chromium] move Tools.gyp, switch build-webkit --chromium to All.gyp
index fe56d92..161f00c 100755 (executable)
@@ -146,7 +146,8 @@ class Port(object):
         self._pretty_patch_path = self.path_from_webkit_base("Websites", "bugs.webkit.org", "PrettyPatch", "prettify.rb")
         self._pretty_patch_available = None
 
-        self.set_option_default('configuration', self.default_configuration())
+        if not options or not options.configuration:
+            self.set_option_default('configuration', self.default_configuration())
         self._test_configuration = None
         self._reftest_list = {}
         self._multiprocessing_is_available = (multiprocessing is not None)
index f7c0bfc..9d1941d 100644 (file)
@@ -36,17 +36,12 @@ import sys
 from common import TabChecker
 from webkitpy.common.host import Host
 from webkitpy.layout_tests.models import test_expectations
+from webkitpy.layout_tests.port.base import DummyOptions
 
 
 _log = logging.getLogger(__name__)
 
 
-# FIXME: This could use mocktool.MockOptions(chromium=True) or base.DummyOptions(chromium=True) instead.
-class ChromiumOptions(object):
-    def __init__(self):
-        self.chromium = True
-
-
 class TestExpectationsChecker(object):
     """Processes test_expectations.txt lines for validating the syntax."""
 
@@ -57,12 +52,13 @@ class TestExpectationsChecker(object):
             # I believe what this is trying to do is "when the port name is chromium,
             # get the chromium-port for this platform".  Unclear why that's needed??
             port_name = expectations_path.split(host.filesystem.sep)[-2]
-            if port_name == "chromium":
-                return host.port_factory.get(options=ChromiumOptions())
-            # Passing port_name=None to the factory would just return the current port, which isn't what we want, I don't think.
             if not port_name:
                 return None
-            return host.port_factory.get(port_name)
+
+            # Pass a configuration to avoid calling default_configuration() when initializing the port (takes 0.5 seconds on a Mac Pro!).
+            if port_name == "chromium":
+                return host.port_factory.get(options=DummyOptions(chromium=True, configuration="Release"))
+            return host.port_factory.get(port_name, options=DummyOptions(configuration="Release"))
         except Exception, e:
             _log.warn("Exception while getting port for path %s" % expectations_path)
             return None