Reland "Measure iOS CPU/GPU percentage (#41234)" (#41426)

This reverts commit f1e7fe8142.

This fix is in https://github.com/flutter/packages/pull/39
This commit is contained in:
liyuqian
2019-09-28 14:24:46 -07:00
committed by GitHub
parent 0223565fd5
commit 67b5bdf99b
11 changed files with 143 additions and 6 deletions

View File

@@ -54,11 +54,21 @@ TaskFunction createCubicBezierPerfTest() {
).run;
}
TaskFunction createBackdropFilterPerfTest() {
TaskFunction createBackdropFilterPerfTest({bool needsMeasureCpuGpu = false}) {
return PerfTest(
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
'test_driver/backdrop_filter_perf.dart',
'backdrop_filter_perf',
needsMeasureCpuGPu: needsMeasureCpuGpu,
).run;
}
TaskFunction createSimpleAnimationPerfTest({bool needsMeasureCpuGpu = false}) {
return PerfTest(
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
'test_driver/simple_animation_perf.dart',
'simple_animation_perf',
needsMeasureCpuGPu: needsMeasureCpuGpu,
).run;
}
@@ -168,12 +178,18 @@ class StartupTest {
/// Measures application runtime performance, specifically per-frame
/// performance.
class PerfTest {
const PerfTest(this.testDirectory, this.testTarget, this.timelineFileName);
const PerfTest(
this.testDirectory,
this.testTarget,
this.timelineFileName,
{this.needsMeasureCpuGPu = false});
final String testDirectory;
final String testTarget;
final String timelineFileName;
final bool needsMeasureCpuGPu;
Future<TaskResult> run() {
return inDirectory<TaskResult>(testDirectory, () async {
final Device device = await devices.workingDevice;
@@ -202,6 +218,12 @@ class PerfTest {
);
}
if (needsMeasureCpuGPu) {
await inDirectory<void>('$testDirectory/build', () async {
data.addAll(await measureIosCpuGpu(deviceId: deviceId));
});
}
return TaskResult.success(data, benchmarkScoreKeys: <String>[
'average_frame_build_time_millis',
'worst_frame_build_time_millis',
@@ -213,6 +235,8 @@ class PerfTest {
'missed_frame_rasterizer_budget_count',
'90th_percentile_frame_rasterizer_time_millis',
'99th_percentile_frame_rasterizer_time_millis',
if (needsMeasureCpuGPu) 'cpu_percentage',
if (needsMeasureCpuGPu) 'gpu_percentage',
]);
});
}