Add a E2E based performance test case (#61509)

This commit is contained in:
Ming Lyu (CareF)
2020-07-23 11:31:04 -04:00
committed by GitHub
parent 8e58c51d1a
commit 056e455e94
8 changed files with 442 additions and 30 deletions

View File

@@ -0,0 +1,14 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/perf_tests.dart';
import 'package:flutter_devicelab/framework/adb.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.android;
await task(createCullOpacityPerfE2ETest());
}

View File

@@ -76,6 +76,13 @@ TaskFunction createCullOpacityPerfTest() {
).run;
}
TaskFunction createCullOpacityPerfE2ETest() {
return E2EPerfTest(
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
'test/cull_opacity_perf_e2e.dart',
).run;
}
TaskFunction createCubicBezierPerfTest() {
return PerfTest(
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
@@ -348,6 +355,8 @@ class PerfTest {
this.timelineFileName, {
this.needsMeasureCpuGpu = false,
this.testDriver,
this.needsFullTimeline = true,
this.benchmarkScoreKeys,
});
/// The directory where the app under test is defined.
@@ -356,10 +365,35 @@ class PerfTest {
final String testTarget;
// The prefix name of the filename such as `<timelineFileName>.timeline_summary.json`.
final String timelineFileName;
String get resultFilename => '$timelineFileName.timeline_summary';
/// The test file to run on the host.
final String testDriver;
/// Whether to collect CPU and GPU metrics.
final bool needsMeasureCpuGpu;
/// Whether to collect full timeline, meaning if `--trace-startup` flag is needed.
final bool needsFullTimeline;
/// The keys of the values that need to be reported.
///
/// If it's `null`, then report:
/// ```Dart
/// <String>[
/// 'average_frame_build_time_millis',
/// 'worst_frame_build_time_millis',
/// '90th_percentile_frame_build_time_millis',
/// '99th_percentile_frame_build_time_millis',
/// 'average_frame_rasterizer_time_millis',
/// 'worst_frame_rasterizer_time_millis',
/// '90th_percentile_frame_rasterizer_time_millis',
/// '99th_percentile_frame_rasterizer_time_millis',
/// 'average_vsync_transitions_missed',
/// '90th_percentile_vsync_transitions_missed',
/// '99th_percentile_vsync_transitions_missed',
/// if (needsMeasureCpuGpu) 'cpu_percentage',
/// if (needsMeasureCpuGpu) 'gpu_percentage',
/// ]
/// ```
final List<String> benchmarkScoreKeys;
Future<TaskResult> run() {
return internalRun();
@@ -382,7 +416,8 @@ class PerfTest {
'-v',
'--verbose-system-logs',
'--profile',
'--trace-startup', // Enables "endless" timeline event buffering.
if (needsFullTimeline)
'--trace-startup', // Enables "endless" timeline event buffering.
'-t', testTarget,
if (noBuild) '--no-build',
if (testDriver != null)
@@ -396,7 +431,7 @@ class PerfTest {
deviceId,
]);
final Map<String, dynamic> data = json.decode(
file('$testDirectory/build/$timelineFileName.timeline_summary.json').readAsStringSync(),
file('$testDirectory/build/$resultFilename.json').readAsStringSync(),
) as Map<String, dynamic>;
if (data['frame_count'] as int < 5) {
@@ -412,25 +447,57 @@ class PerfTest {
});
}
return TaskResult.success(data, benchmarkScoreKeys: <String>[
'average_frame_build_time_millis',
'worst_frame_build_time_millis',
'90th_percentile_frame_build_time_millis',
'99th_percentile_frame_build_time_millis',
'average_frame_rasterizer_time_millis',
'worst_frame_rasterizer_time_millis',
'90th_percentile_frame_rasterizer_time_millis',
'99th_percentile_frame_rasterizer_time_millis',
'average_vsync_transitions_missed',
'90th_percentile_vsync_transitions_missed',
'99th_percentile_vsync_transitions_missed',
if (needsMeasureCpuGpu) 'cpu_percentage',
if (needsMeasureCpuGpu) 'gpu_percentage',
]);
return TaskResult.success(
data,
benchmarkScoreKeys: benchmarkScoreKeys ?? <String>[
'average_frame_build_time_millis',
'worst_frame_build_time_millis',
'90th_percentile_frame_build_time_millis',
'99th_percentile_frame_build_time_millis',
'average_frame_rasterizer_time_millis',
'worst_frame_rasterizer_time_millis',
'90th_percentile_frame_rasterizer_time_millis',
'99th_percentile_frame_rasterizer_time_millis',
'average_vsync_transitions_missed',
'90th_percentile_vsync_transitions_missed',
'99th_percentile_vsync_transitions_missed',
if (needsMeasureCpuGpu) 'cpu_percentage',
if (needsMeasureCpuGpu) 'gpu_percentage',
],
);
});
}
}
class E2EPerfTest extends PerfTest {
const E2EPerfTest(
String testDirectory,
String testTarget, {
String summaryFilename,
List<String> benchmarkScoreKeys,
}
) : super(
testDirectory,
testTarget,
summaryFilename,
testDriver: 'test_driver/e2e_test.dart',
needsFullTimeline: false,
benchmarkScoreKeys: benchmarkScoreKeys ?? const <String>[
'average_frame_build_time_millis',
'worst_frame_build_time_millis',
'90th_percentile_frame_build_time_millis',
'99th_percentile_frame_build_time_millis',
'average_frame_rasterizer_time_millis',
'worst_frame_rasterizer_time_millis',
'90th_percentile_frame_rasterizer_time_millis',
'99th_percentile_frame_rasterizer_time_millis',
],
);
@override
String get resultFilename => timelineFileName ?? 'e2e_perf_summary';
}
class PerfTestWithSkSL extends PerfTest {
PerfTestWithSkSL(
String testDirectory,

View File

@@ -161,6 +161,13 @@ tasks:
stage: devicelab
required_agent_capabilities: ["mac/android"]
cull_opacity_perf__e2e_summary:
description: >
Measures the runtime performance of culling opacity widgets on Android on
E2E with self-driving test app.
stage: devicelab
required_agent_capabilities: ["linux/android"]
multi_widget_construction_perf__timeline_summary:
description: >
Measures the runtime performance of constructing and destructing widgets on Android.