Commit ae678df0 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

[WPT/common/security-features] Faster generator by less json.dumps()

Previously, dump_test_parameters() (which uses json.dumps())
was used to calculate the keys of `exclusion_dict`,
so that the keys of `exclusion_dict` include
all the fields of the selections.

However, this was slow.
This CL instead uses `excluded_selection_pattern % selection`
where excluded_selection_pattern incudes "`%(key)s`" for
all the keys of the selections, except for "expansion".
(The exclusion of "expansion" is probably good, as
differences in "expansion" fields shouldn't prevent
excluded test matching)

This CL improves the generator's performance about 5x.

This CL doesn't change the generated results or test behavior.

Bug: 906850
Change-Id: I67f2cf6e960d7867a9b409cb84bf8249ac1912c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2100562
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarKenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750484}
parent 6f416959
......@@ -254,15 +254,19 @@ def generate_test_source_files(spec_directory, test_helper_filenames,
artifact_order = test_expansion_schema.keys()
artifact_order.remove('expansion')
excluded_selection_pattern = ''
for key in artifact_order:
excluded_selection_pattern += '%(' + key + ')s/'
# Create list of excluded tests.
exclusion_dict = {}
exclusion_dict = set()
for excluded_pattern in spec_json['excluded_tests']:
excluded_expansion = \
expand_pattern(excluded_pattern, test_expansion_schema)
for excluded_selection in permute_expansion(excluded_expansion,
artifact_order):
excluded_selection['delivery_key'] = spec_json['delivery_key']
exclusion_dict[dump_test_parameters(excluded_selection)] = True
exclusion_dict.add(excluded_selection_pattern % excluded_selection)
for spec in specification:
# Used to make entries with expansion="override" override preceding
......@@ -287,7 +291,7 @@ def generate_test_source_files(spec_directory, test_helper_filenames,
for selection_path in output_dict:
selection = output_dict[selection_path]
if dump_test_parameters(selection) in exclusion_dict:
if (excluded_selection_pattern % selection) in exclusion_dict:
print('Excluding selection:', selection_path)
continue
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment