Introduce image loading performance test. (#34823)
* Introduce image loading performance test. This example reports how long it takes to load images over the network(locally spawned server).
This commit is contained in:
committed by
GitHub
parent
25f31bf14a
commit
3badcf51a4
18
dev/devicelab/bin/tasks/image_list_reported_duration.dart
Normal file
18
dev/devicelab/bin/tasks/image_list_reported_duration.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright 2016 The Chromium 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/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await task(ReportedDurationTest(
|
||||
'${flutterDirectory.path}/examples/image_list',
|
||||
'lib/main.dart',
|
||||
'com.example.image_list',
|
||||
RegExp(r'===image_list=== all loaded in ([\d]+)ms.'),
|
||||
).run);
|
||||
}
|
||||
@@ -607,6 +607,65 @@ class MemoryTest {
|
||||
}
|
||||
}
|
||||
|
||||
class ReportedDurationTest {
|
||||
ReportedDurationTest(this.project, this.test, this.package, this.durationPattern);
|
||||
|
||||
final String project;
|
||||
final String test;
|
||||
final String package;
|
||||
final RegExp durationPattern;
|
||||
|
||||
final Completer<int> durationCompleter = Completer<int>();
|
||||
|
||||
int get iterationCount => 10;
|
||||
|
||||
Device get device => _device;
|
||||
Device _device;
|
||||
|
||||
Future<TaskResult> run() {
|
||||
return inDirectory<TaskResult>(project, () async {
|
||||
// This test currently only works on Android, because device.logcat,
|
||||
// device.getMemoryStats, etc, aren't implemented for iOS.
|
||||
|
||||
_device = await devices.workingDevice;
|
||||
await device.unlock();
|
||||
await flutter('packages', options: <String>['get']);
|
||||
|
||||
if (deviceOperatingSystem == DeviceOperatingSystem.ios)
|
||||
await prepareProvisioningCertificates(project);
|
||||
|
||||
final StreamSubscription<String> adb = device.logcat.listen(
|
||||
(String data) {
|
||||
if (durationPattern.hasMatch(data))
|
||||
durationCompleter.complete(int.parse(durationPattern.firstMatch(data).group(1)));
|
||||
},
|
||||
);
|
||||
print('launching $project$test on device...');
|
||||
await flutter('run', options: <String>[
|
||||
'--verbose',
|
||||
'--release',
|
||||
'--no-resident',
|
||||
'-d', device.deviceId,
|
||||
test,
|
||||
]);
|
||||
|
||||
final int duration = await durationCompleter.future;
|
||||
print('terminating...');
|
||||
await device.stop(package);
|
||||
await adb.cancel();
|
||||
|
||||
_device = null;
|
||||
|
||||
final Map<String, dynamic> reportedDuration = <String, dynamic>{
|
||||
'duration': duration
|
||||
};
|
||||
_device = null;
|
||||
|
||||
return TaskResult.success(reportedDuration, benchmarkScoreKeys: reportedDuration.keys.toList());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Holds simple statistics of an odd-lengthed list of integers.
|
||||
class ListStatistics {
|
||||
factory ListStatistics(Iterable<int> data) {
|
||||
|
||||
@@ -350,6 +350,12 @@ tasks:
|
||||
stage: devicelab
|
||||
required_agent_capabilities: ["linux/android"]
|
||||
|
||||
image_list_reported_duration:
|
||||
description: >
|
||||
Measures image loading performance.
|
||||
stage: devicelab
|
||||
required_agent_capabilities: ["linux/android"]
|
||||
flaky: true
|
||||
|
||||
# iOS on-device tests
|
||||
|
||||
|
||||
Reference in New Issue
Block a user