Skip to content

Commit dc57d53

Browse files
authored
Fix benchmark tests (#9696)
1 parent dbd787f commit dc57d53

2 files changed

Lines changed: 45 additions & 22 deletions

File tree

packages/devtools_app/benchmark/devtools_benchmarks_test.dart

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'dart:convert' show JsonEncoder;
99
import 'dart:io';
1010

1111
import 'package:collection/collection.dart';
12+
import 'package:devtools_test/helpers.dart';
1213
import 'package:test/test.dart';
1314
import 'package:web_benchmarks/metrics.dart';
1415
import 'package:web_benchmarks/server.dart';
@@ -44,29 +45,51 @@ void main() {
4445
},
4546
timeout: const Timeout(Duration(minutes: 15)),
4647
retry: 0,
47-
// TODO(elliette): Re-enable once flakiness is addressed.
48-
skip: 'https://github.com/flutter/devtools/issues/9674',
4948
);
5049
}
5150
}
5251

5352
Future<void> _runBenchmarks({bool useWasm = false}) async {
5453
stdout.writeln('Starting web benchmark tests ...');
5554

56-
final benchmarkPort = await _findAvailablePort(startingAt: 9999);
57-
final chromePort = await _findAvailablePort(startingAt: benchmarkPort + 1);
55+
var benchmarkPort = await _findAvailablePort(startingAt: 9999);
56+
var chromePort = await _findAvailablePort(startingAt: benchmarkPort + 1);
5857

59-
final taskResult = await serveWebBenchmark(
60-
benchmarkAppDirectory: projectRootDirectory(),
61-
entryPoint: generateBenchmarkEntryPoint(useWasm: useWasm),
62-
compilationOptions: useWasm
63-
? const CompilationOptions.wasm()
64-
: const CompilationOptions.js(),
65-
treeShakeIcons: false,
66-
benchmarkPath: benchmarkPath(useWasm: useWasm),
67-
benchmarkServerPort: benchmarkPort,
68-
chromeDebugPort: chromePort,
58+
// TODO(elliette): Retry logic can likely be removed after
59+
// https://github.com/flutter/flutter/issues/183335 is resolved.
60+
final taskResult = await retryAsync<BenchmarkResults?>(
61+
() async {
62+
try {
63+
logStatus(
64+
'Serving benchmarks (server port: $benchmarkPort, chrome port: $chromePort)',
65+
);
66+
return await serveWebBenchmark(
67+
benchmarkAppDirectory: projectRootDirectory(),
68+
entryPoint: generateBenchmarkEntryPoint(useWasm: useWasm),
69+
compilationOptions: useWasm
70+
? const CompilationOptions.wasm()
71+
: const CompilationOptions.js(),
72+
treeShakeIcons: false,
73+
benchmarkPath: benchmarkPath(useWasm: useWasm),
74+
benchmarkServerPort: benchmarkPort,
75+
chromeDebugPort: chromePort,
76+
);
77+
} catch (e) {
78+
logStatus('Serving benchmarks failed with error: $e');
79+
return null;
80+
}
81+
},
82+
condition: (result) => result != null,
83+
onRetry: () async {
84+
logStatus('Retrying with new ports...');
85+
benchmarkPort = await _findAvailablePort(startingAt: chromePort + 1);
86+
chromePort = await _findAvailablePort(startingAt: benchmarkPort + 1);
87+
},
6988
);
89+
if (taskResult == null) {
90+
throw Exception('Failed to serve benchmarks after retries.');
91+
}
92+
7093
stdout.writeln('Web benchmark tests finished.');
7194

7295
expect(

pubspec.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,10 @@ packages:
530530
dependency: transitive
531531
description:
532532
name: matcher
533-
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
533+
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
534534
url: "https://pub.dev"
535535
source: hosted
536-
version: "0.12.19"
536+
version: "0.12.18"
537537
material_color_utilities:
538538
dependency: transitive
539539
description:
@@ -854,26 +854,26 @@ packages:
854854
dependency: transitive
855855
description:
856856
name: test
857-
sha256: "280d6d890011ca966ad08df7e8a4ddfab0fb3aa49f96ed6de56e3521347a9ae7"
857+
sha256: "54c516bbb7cee2754d327ad4fca637f78abfc3cbcc5ace83b3eda117e42cd71a"
858858
url: "https://pub.dev"
859859
source: hosted
860-
version: "1.30.0"
860+
version: "1.29.0"
861861
test_api:
862862
dependency: transitive
863863
description:
864864
name: test_api
865-
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
865+
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
866866
url: "https://pub.dev"
867867
source: hosted
868-
version: "0.7.10"
868+
version: "0.7.9"
869869
test_core:
870870
dependency: transitive
871871
description:
872872
name: test_core
873-
sha256: "0381bd1585d1a924763c308100f2138205252fb90c9d4eeaf28489ee65ccde51"
873+
sha256: "394f07d21f0f2255ec9e3989f21e54d3c7dc0e6e9dbce160e5a9c1a6be0e2943"
874874
url: "https://pub.dev"
875875
source: hosted
876-
version: "0.6.16"
876+
version: "0.6.15"
877877
typed_data:
878878
dependency: transitive
879879
description:

0 commit comments

Comments
 (0)