Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use enum
  • Loading branch information
kenzieschmoll committed Dec 5, 2023
commit ea22ce02679ec30a06c43da4dfa5318159b53a76
2 changes: 2 additions & 0 deletions packages/devtools_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,5 @@ dependency_overrides:
path: ../devtools_test
devtools_extensions:
path: ../devtools_extensions
web_benchmarks:
path: ../../../packages/packages/web_benchmarks
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ Future<void> main() async {

stdout.writeln('Web benchmark tests finished.');

expect(taskResult.scores.keys, hasLength(benchmarkList.length));
expect(
taskResult.scores.keys,
hasLength(DevToolsBenchmark.values.length),
);

for (final benchmarkName in benchmarkList) {
for (final benchmarkName in DevToolsBenchmark.values.map((e) => e.id)) {
expect(
taskResult.scores[benchmarkName],
hasLength(metricList.length * valueList.length + 1),
Expand Down
4 changes: 3 additions & 1 deletion packages/devtools_app/test_benchmarks/test_infra/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import 'devtools_recorder.dart';
typedef RecorderFactory = Recorder Function();

final Map<String, RecorderFactory> benchmarks = <String, RecorderFactory>{
devtoolsPageLoadPerf: () => DevToolsRecorder(benchmarkName: devtoolsPageLoadPerf),
DevToolsBenchmark.navigateThroughOfflineScreens.id: () => DevToolsRecorder(
benchmark: DevToolsBenchmark.navigateThroughOfflineScreens,
),
};

/// Runs the client of the DevTools web benchmarks.
Expand Down
10 changes: 5 additions & 5 deletions packages/devtools_app/test_benchmarks/test_infra/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

const String devtoolsBenchmarkPrefix = 'devtools';

const String devtoolsPageLoadPerf = '${devtoolsBenchmarkPrefix}_page_load_perf';

/// The initial page to load upon opening the DevTools benchmark app or
/// reloading it in Chrome.
//
Expand All @@ -14,6 +12,8 @@ const String devtoolsPageLoadPerf = '${devtoolsBenchmarkPrefix}_page_load_perf';
// found" in DevTools.
const String benchmarkInitialPage = '';

const benchmarkList = <String>[
devtoolsPageLoadPerf,
];
enum DevToolsBenchmark {
navigateThroughOfflineScreens;

String get id => '${devtoolsBenchmarkPrefix}_$name';
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import 'package:devtools_test/helpers.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'common.dart';
import 'scroll.dart';

/// A class that automates the DevTools web app.
class DevToolsAutomater {
DevToolsAutomater({
required this.benchmarkName,
required this.benchmark,
required this.stopWarmingUpCallback,
});

/// The name of the current benchmark.
final String benchmarkName;
/// The current benchmark.
final DevToolsBenchmark benchmark;

/// A function to call when warm-up is finished.
///
Expand Down Expand Up @@ -45,12 +46,10 @@ class DevToolsAutomater {
Future<void> automateDevToolsGestures() async {
await warmUp();

_logStatus('==== Navigate through DevTools tabs ====');
await navigateThroughDevToolsScreens(
controller,
runWithExpectations: false,
);
_logStatus('==== End of navigate through DevTools tabs ====');
switch (benchmark) {
case DevToolsBenchmark.navigateThroughOfflineScreens:
await _handleNavigateThroughOfflineScreens();
}

// At the end of the test, mark as finished.
finished = true;
Expand All @@ -76,6 +75,14 @@ class DevToolsAutomater {

_logStatus('Warm-up finished.');
}

Future<void> _handleNavigateThroughOfflineScreens() async {
_logStatus('==== Navigate through offline DevTools tabs ====');
await navigateThroughDevToolsScreens(
controller,
runWithExpectations: false,
);
_logStatus('==== End navigate through offline DevTools tabs ====');
}

void _logStatus(String log) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import 'package:devtools_app/initialization.dart';
import 'package:flutter/material.dart';
import 'package:web_benchmarks/client.dart';

import 'common.dart';
import 'devtools_automator.dart';

/// A recorder that measures frame building durations for the DevTools.
class DevToolsRecorder extends WidgetRecorder {
DevToolsRecorder({required this.benchmarkName})
: super(name: benchmarkName, useCustomWarmUp: true);
DevToolsRecorder({required this.benchmark})
: super(name: benchmark.id, useCustomWarmUp: true);

/// The name of the DevTools benchmark to be run.
///
/// See `common.dart` for the list of the names of all benchmarks.
final String benchmarkName;
final DevToolsBenchmark benchmark;

DevToolsAutomater? _devToolsAutomator;
bool get _finished => _devToolsAutomator?.finished ?? false;
Expand All @@ -29,7 +30,7 @@ class DevToolsRecorder extends WidgetRecorder {
@override
Widget createWidget() {
_devToolsAutomator = DevToolsAutomater(
benchmarkName: benchmarkName,
benchmark: benchmark,
stopWarmingUpCallback: profile.stopWarmingUp,
);
return _devToolsAutomator!.createWidget();
Expand Down