[test] Avoid quadratic complexity in vm/dart/unobfuscated_static_symbols_test

This change makes this test much faster and should fix the timeouts on
the slow simarm_x64 configuration.

Change-Id: I6ba489d2dee3963bb070c1e86abff88420fa3ce7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306900
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov 2023-06-01 17:36:29 +00:00 committed by Commit Queue
parent e316fb84a1
commit 63d856d487

View file

@ -224,27 +224,29 @@ Future<void> checkTraces(
void checkStaticSymbolTables(TestCase expected, List<TestCase> cases) {
final expectedSymbolNames =
expected.container.staticSymbols.map((o) => o.name);
expected.container.staticSymbols.map((o) => o.name).toSet();
if (expected.debuggingInfoContainer != null) {
expectSimilarStaticSymbols(expectedSymbolNames,
expected.debuggingInfoContainer!.staticSymbols.map((o) => o.name));
expectSimilarStaticSymbols(
expectedSymbolNames,
expected.debuggingInfoContainer!.staticSymbols
.map((o) => o.name)
.toSet());
}
for (final got in cases) {
expectSimilarStaticSymbols(
expectedSymbolNames, got.container.staticSymbols.map((o) => o.name));
expectSimilarStaticSymbols(expectedSymbolNames,
got.container.staticSymbols.map((o) => o.name).toSet());
if (got.debuggingInfoContainer != null) {
expectSimilarStaticSymbols(expectedSymbolNames,
got.debuggingInfoContainer!.staticSymbols.map((o) => o.name));
got.debuggingInfoContainer!.staticSymbols.map((o) => o.name).toSet());
}
}
}
const kMaxPercentAllowedDifferences = 0.01;
void expectSimilarStaticSymbols(
Iterable<String> expected, Iterable<String> got) {
void expectSimilarStaticSymbols(Set<String> expected, Set<String> got) {
final allowedDifferences =
(expected.length * kMaxPercentAllowedDifferences).floor();
// There are cases where we cannot assume that we have the exact same symbols