Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2717)

Unified Diff: Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py

Issue 1182253003: Parsing expectations is n^2 in the number of tests per line. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
diff --git a/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py b/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
index 641572f60c66de9f476288a77e651dcbadbbcdaa..ae3b853793c066aa13bf5eb83439b152abe8d3ea 100644
--- a/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
+++ b/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
@@ -30,6 +30,8 @@
for layout tests.
"""
+from collections import defaultdict
+
import logging
import re
@@ -563,9 +565,26 @@ class TestExpectationsModel(object):
def merge_model(self, other):
self._merge_test_map(self._test_to_expectations, other._test_to_expectations)
+ # This code is n^2 in the number of tests per line. Cache the output
Dirk Pranke 2015/06/15 22:50:59 "This code" is a bit ambiguous. It's merge_expec
ojan 2015/06/17 17:16:53 Done
+ # of merge_expectation_lines so that we only call that n^2 in the number
+ # of *lines*.
+ merge_lines_cache = defaultdict(dict)
+
for test, line in other._test_to_expectation_line.items():
if test in self._test_to_expectation_line:
- line = TestExpectationLine.merge_expectation_lines(self._test_to_expectation_line[test], line, model_all_expectations=False)
+ self_line = self._test_to_expectation_line[test]
+
+ cached_line = None
+ if self_line in merge_lines_cache:
+ cached_line = merge_lines_cache[self_line].get(line)
+
+ if cached_line:
+ line = cached_line
+ else:
+ new_line = TestExpectationLine.merge_expectation_lines(self_line, line, model_all_expectations=False)
+ merge_lines_cache[self_line][line] = new_line
+ line = new_line
Dirk Pranke 2015/06/15 22:50:59 Can you rewrite lines 577-586 as: if line not in
ojan 2015/06/17 17:16:53 That's much better. I didn't do exactly this, but
+
self._test_to_expectation_line[test] = line
self._merge_dict_of_sets(self._expectation_to_tests, other._expectation_to_tests)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698