Use task name when uploading metrics to skia perf (#89004)
This commit is contained in:
parent
7df68b906c
commit
db4c104c8e
@ -42,7 +42,7 @@ dependencies:
|
||||
json_annotation: 4.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
logging: 1.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
matcher: 0.12.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
metrics_center: 1.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
metrics_center: 1.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
mime: 1.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
node_preamble: 2.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
package_config: 2.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
@ -72,4 +72,4 @@ dependencies:
|
||||
dev_dependencies:
|
||||
test_api: 0.4.3
|
||||
|
||||
# PUBSPEC CHECKSUM: e827
|
||||
# PUBSPEC CHECKSUM: 3028
|
||||
|
@ -21,6 +21,7 @@ class UploadResultsCommand extends Command<void> {
|
||||
'checkouts run in detached HEAD state, so the branch must be passed.',
|
||||
);
|
||||
argParser.addOption('luci-builder', help: '[Flutter infrastructure] Name of the LUCI builder being run on.');
|
||||
argParser.addOption('task-name', help: '[Flutter infrastructure] Name of the task being run on.');
|
||||
argParser.addOption('test-status', help: 'Test status: Succeeded|Failed');
|
||||
argParser.addOption('commit-time', help: 'Commit time in UNIX timestamp');
|
||||
}
|
||||
@ -40,6 +41,7 @@ class UploadResultsCommand extends Command<void> {
|
||||
final String? builderName = argResults!['luci-builder'] as String?;
|
||||
final String? testStatus = argResults!['test-status'] as String?;
|
||||
final String? commitTime = argResults!['commit-time'] as String?;
|
||||
final String? taskName = argResults!['task-name'] as String?;
|
||||
|
||||
// Upload metrics to metrics_center from test runner when `commitTime` is specified. This
|
||||
// is mainly for testing purpose.
|
||||
@ -47,7 +49,7 @@ class UploadResultsCommand extends Command<void> {
|
||||
// TODO(keyong): remove try block to block test when this is validated to work https://github.com/flutter/flutter/issues/88484
|
||||
try {
|
||||
if (commitTime != null) {
|
||||
await uploadToMetricsCenter(resultsPath, commitTime);
|
||||
await uploadToMetricsCenter(resultsPath, commitTime, taskName);
|
||||
print('Successfully uploaded metrics to metrics center');
|
||||
}
|
||||
} on Exception catch (e, stacktrace) {
|
||||
|
@ -70,8 +70,33 @@ List<MetricPoint> parse(Map<String, dynamic> resultsJson) {
|
||||
return metricPoints;
|
||||
}
|
||||
|
||||
/// Upload metrics to GCS bucket used by Skia Perf.
|
||||
///
|
||||
/// Skia Perf picks up all available files under the folder, and
|
||||
/// is robust to duplicate entries.
|
||||
///
|
||||
/// Files will be named based on `taskName`, such as
|
||||
/// `complex_layout_scroll_perf__timeline_summary_values.json`.
|
||||
/// If no `taskName` is specified, data will be saved to
|
||||
/// `default_values.json`.
|
||||
Future<void> upload(
|
||||
FlutterDestination metricsDestination,
|
||||
List<MetricPoint> metricPoints,
|
||||
int commitTimeSinceEpoch,
|
||||
String? taskName,
|
||||
) async {
|
||||
await metricsDestination.update(
|
||||
metricPoints,
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
commitTimeSinceEpoch,
|
||||
isUtc: true,
|
||||
),
|
||||
taskName ?? 'default',
|
||||
);
|
||||
}
|
||||
|
||||
/// Upload test metrics to metrics center.
|
||||
Future<void> uploadToMetricsCenter(String? resultsPath, String? commitTime) async {
|
||||
Future<void> uploadToMetricsCenter(String? resultsPath, String? commitTime, String? taskName) async {
|
||||
int commitTimeSinceEpoch;
|
||||
if (resultsPath == null) {
|
||||
return;
|
||||
@ -86,11 +111,5 @@ Future<void> uploadToMetricsCenter(String? resultsPath, String? commitTime) asyn
|
||||
resultsJson = json.decode(await resultFile.readAsString()) as Map<String, dynamic>;
|
||||
final List<MetricPoint> metricPoints = parse(resultsJson);
|
||||
final FlutterDestination metricsDestination = await connectFlutterDestination();
|
||||
await metricsDestination.update(
|
||||
metricPoints,
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
commitTimeSinceEpoch,
|
||||
isUtc: true,
|
||||
),
|
||||
);
|
||||
await upload(metricsDestination, metricPoints, commitTimeSinceEpoch, taskName);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ dependencies:
|
||||
file: 6.1.2
|
||||
http: 0.13.3
|
||||
meta: 1.7.0
|
||||
metrics_center: 1.0.0
|
||||
metrics_center: 1.0.1
|
||||
path: 1.8.0
|
||||
platform: 3.0.2
|
||||
process: 4.2.3
|
||||
@ -73,4 +73,4 @@ dev_dependencies:
|
||||
web_socket_channel: 2.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
webkit_inspection_protocol: 1.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
|
||||
# PUBSPEC CHECKSUM: e827
|
||||
# PUBSPEC CHECKSUM: 3028
|
||||
|
@ -7,6 +7,21 @@ import 'package:metrics_center/metrics_center.dart';
|
||||
|
||||
import 'common.dart';
|
||||
|
||||
class FakeFlutterDestination implements FlutterDestination {
|
||||
/// Overrides the skia perf `update` function, which uploads new data to gcs if there
|
||||
/// doesn't exist the commit, otherwise updates existing data by appending new ones.
|
||||
@override
|
||||
Future<void> update(List<MetricPoint> points, DateTime commitTime, String taskName) async {
|
||||
lastUpdatedPoints = points;
|
||||
time = commitTime;
|
||||
name = taskName;
|
||||
}
|
||||
|
||||
List<MetricPoint>? lastUpdatedPoints;
|
||||
DateTime? time;
|
||||
String? name;
|
||||
}
|
||||
|
||||
void main() {
|
||||
group('Parse', () {
|
||||
test('succeeds', () {
|
||||
@ -42,4 +57,54 @@ void main() {
|
||||
expect(metricPoints.length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
group('Update', () {
|
||||
test('without taskName', () async {
|
||||
final Map<String, dynamic> results = <String, dynamic>{
|
||||
'CommitBranch': 'master',
|
||||
'CommitSha': 'abc',
|
||||
'BuilderName': 'test',
|
||||
'ResultData': <String, dynamic>{
|
||||
'average_frame_build_time_millis': 0.4550425531914895,
|
||||
'90th_percentile_frame_build_time_millis': 0.473,
|
||||
},
|
||||
'BenchmarkScoreKeys': <String>[
|
||||
'average_frame_build_time_millis',
|
||||
'90th_percentile_frame_build_time_millis',
|
||||
],
|
||||
};
|
||||
final List<MetricPoint> metricPoints = parse(results);
|
||||
final FakeFlutterDestination flutterDestination = FakeFlutterDestination();
|
||||
String? taskName;
|
||||
const int commitTimeSinceEpoch = 1629220312;
|
||||
|
||||
await upload(flutterDestination, metricPoints, commitTimeSinceEpoch, taskName);
|
||||
|
||||
expect(flutterDestination.name, 'default');
|
||||
});
|
||||
|
||||
test('with taskName', () async {
|
||||
final Map<String, dynamic> results = <String, dynamic>{
|
||||
'CommitBranch': 'master',
|
||||
'CommitSha': 'abc',
|
||||
'BuilderName': 'test',
|
||||
'ResultData': <String, dynamic>{
|
||||
'average_frame_build_time_millis': 0.4550425531914895,
|
||||
'90th_percentile_frame_build_time_millis': 0.473,
|
||||
},
|
||||
'BenchmarkScoreKeys': <String>[
|
||||
'average_frame_build_time_millis',
|
||||
'90th_percentile_frame_build_time_millis',
|
||||
],
|
||||
};
|
||||
final List<MetricPoint> metricPoints = parse(results);
|
||||
final FakeFlutterDestination flutterDestination = FakeFlutterDestination();
|
||||
const String taskName = 'test';
|
||||
const int commitTimeSinceEpoch = 1629220312;
|
||||
|
||||
await upload(flutterDestination, metricPoints, commitTimeSinceEpoch, taskName);
|
||||
|
||||
expect(flutterDestination.name, taskName);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user