mirror of
https://github.com/flutter/packages.git
synced 2025-07-03 00:49:32 +08:00
FlutterDestination writes into GCS (#269)
For now, we also preserve the datastore writing. We'll eventually remove the datastore writing.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
# 0.0.5
|
||||||
|
|
||||||
|
- `FlutterDestination` writes into both Skia perf GCS and the legacy datastore.
|
||||||
|
- `FlutterDestination.makeFromAccessToken` returns a `Future`.
|
||||||
|
|
||||||
# 0.0.4+1
|
# 0.0.4+1
|
||||||
|
|
||||||
- Moved to the `flutter/packages` repository
|
- Moved to the `flutter/packages` repository
|
||||||
|
@ -6,6 +6,7 @@ import 'common.dart';
|
|||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
import 'legacy_datastore.dart';
|
import 'legacy_datastore.dart';
|
||||||
import 'legacy_flutter.dart';
|
import 'legacy_flutter.dart';
|
||||||
|
import 'skiaperf.dart';
|
||||||
|
|
||||||
/// Convenient class to capture the benchmarks in the Flutter engine repo.
|
/// Convenient class to capture the benchmarks in the Flutter engine repo.
|
||||||
class FlutterEngineMetricPoint extends MetricPoint {
|
class FlutterEngineMetricPoint extends MetricPoint {
|
||||||
@ -33,28 +34,38 @@ class FlutterDestination extends MetricDestination {
|
|||||||
// TODO(liyuqian): change the implementation of this class (without changing
|
// TODO(liyuqian): change the implementation of this class (without changing
|
||||||
// its public APIs) to remove `LegacyFlutterDestination` and directly use
|
// its public APIs) to remove `LegacyFlutterDestination` and directly use
|
||||||
// `SkiaPerfDestination` once the migration is fully done.
|
// `SkiaPerfDestination` once the migration is fully done.
|
||||||
FlutterDestination._(this._legacyDestination);
|
FlutterDestination._(this._legacyDestination, this._skiaPerfDestination);
|
||||||
|
|
||||||
/// Creates a [FlutterDestination] from service account JSON.
|
/// Creates a [FlutterDestination] from service account JSON.
|
||||||
static Future<FlutterDestination> makeFromCredentialsJson(
|
static Future<FlutterDestination> makeFromCredentialsJson(
|
||||||
Map<String, dynamic> json) async {
|
Map<String, dynamic> json,
|
||||||
|
{bool isTesting = false}) async {
|
||||||
final LegacyFlutterDestination legacyDestination =
|
final LegacyFlutterDestination legacyDestination =
|
||||||
LegacyFlutterDestination(await datastoreFromCredentialsJson(json));
|
LegacyFlutterDestination(await datastoreFromCredentialsJson(json));
|
||||||
return FlutterDestination._(legacyDestination);
|
final SkiaPerfDestination skiaPerfDestination =
|
||||||
|
await SkiaPerfDestination.makeFromGcpCredentials(json,
|
||||||
|
isTesting: isTesting);
|
||||||
|
return FlutterDestination._(legacyDestination, skiaPerfDestination);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a [FlutterDestination] from an OAuth access token.
|
/// Creates a [FlutterDestination] from an OAuth access token.
|
||||||
static FlutterDestination makeFromAccessToken(
|
static Future<FlutterDestination> makeFromAccessToken(
|
||||||
String accessToken, String projectId) {
|
String accessToken, String projectId,
|
||||||
|
{bool isTesting = false}) async {
|
||||||
final LegacyFlutterDestination legacyDestination = LegacyFlutterDestination(
|
final LegacyFlutterDestination legacyDestination = LegacyFlutterDestination(
|
||||||
datastoreFromAccessToken(accessToken, projectId));
|
datastoreFromAccessToken(accessToken, projectId));
|
||||||
return FlutterDestination._(legacyDestination);
|
final SkiaPerfDestination skiaPerfDestination =
|
||||||
|
await SkiaPerfDestination.makeFromAccessToken(accessToken, projectId,
|
||||||
|
isTesting: isTesting);
|
||||||
|
return FlutterDestination._(legacyDestination, skiaPerfDestination);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> update(List<MetricPoint> points) async {
|
Future<void> update(List<MetricPoint> points) async {
|
||||||
await _legacyDestination.update(points);
|
await _legacyDestination.update(points);
|
||||||
|
await _skiaPerfDestination.update(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
final LegacyFlutterDestination _legacyDestination;
|
final LegacyFlutterDestination _legacyDestination;
|
||||||
|
final SkiaPerfDestination _skiaPerfDestination;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: metrics_center
|
name: metrics_center
|
||||||
version: 0.0.4+1
|
version: 0.0.5
|
||||||
description:
|
description:
|
||||||
Support multiple performance metrics sources/formats and destinations.
|
Support multiple performance metrics sources/formats and destinations.
|
||||||
homepage:
|
homepage:
|
||||||
|
@ -6,15 +6,17 @@ import 'package:metrics_center/src/constants.dart';
|
|||||||
import 'package:metrics_center/src/flutter.dart';
|
import 'package:metrics_center/src/flutter.dart';
|
||||||
|
|
||||||
import 'common.dart';
|
import 'common.dart';
|
||||||
|
import 'utility.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
const String gitRevision = 'ca799fa8b2254d09664b78ee80c43b434788d112';
|
||||||
|
final FlutterEngineMetricPoint simplePoint = FlutterEngineMetricPoint(
|
||||||
|
'BM_ParagraphLongLayout',
|
||||||
|
287235,
|
||||||
|
gitRevision,
|
||||||
|
);
|
||||||
|
|
||||||
test('FlutterEngineMetricPoint works.', () {
|
test('FlutterEngineMetricPoint works.', () {
|
||||||
const String gitRevision = 'ca799fa8b2254d09664b78ee80c43b434788d112';
|
|
||||||
final FlutterEngineMetricPoint simplePoint = FlutterEngineMetricPoint(
|
|
||||||
'BM_ParagraphLongLayout',
|
|
||||||
287235,
|
|
||||||
gitRevision,
|
|
||||||
);
|
|
||||||
expect(simplePoint.value, equals(287235));
|
expect(simplePoint.value, equals(287235));
|
||||||
expect(simplePoint.tags[kGithubRepoKey], kFlutterEngineRepo);
|
expect(simplePoint.tags[kGithubRepoKey], kFlutterEngineRepo);
|
||||||
expect(simplePoint.tags[kGitRevisionKey], gitRevision);
|
expect(simplePoint.tags[kGitRevisionKey], gitRevision);
|
||||||
@ -35,4 +37,13 @@ void main() {
|
|||||||
expect(detailedPoint.tags['sub_result'], equals('CPU'));
|
expect(detailedPoint.tags['sub_result'], equals('CPU'));
|
||||||
expect(detailedPoint.tags[kUnitKey], equals('ns'));
|
expect(detailedPoint.tags[kUnitKey], equals('ns'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final Map<String, dynamic> credentialsJson = getTestGcpCredentialsJson();
|
||||||
|
|
||||||
|
test('FlutterDestination integration test with update.', () async {
|
||||||
|
final FlutterDestination dst =
|
||||||
|
await FlutterDestination.makeFromCredentialsJson(credentialsJson,
|
||||||
|
isTesting: true);
|
||||||
|
dst.update(<FlutterEngineMetricPoint>[simplePoint]);
|
||||||
|
}, skip: credentialsJson == null);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user