Adding first semantics perf test (#10649)

* Adding first semantics perf test

* review commnts and analyzer fixes

* fix analyzer warning
This commit is contained in:
Michael Goderbauer
2017-06-13 12:49:07 -07:00
committed by GitHub
parent 0774c5194b
commit 8bf17192f6
8 changed files with 182 additions and 1 deletions

View File

@@ -0,0 +1,11 @@
// Copyright 2017 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 'package:flutter_driver/driver_extension.dart';
import 'package:complex_layout/main.dart' as app;
void main() {
enableFlutterDriverExtension();
app.main();
}

View File

@@ -0,0 +1,43 @@
// Copyright 2017 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 'dart:convert';
import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';
void main() {
group('semantics performance test', () {
FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect(printCommunication: true);
});
tearDownAll(() async {
if (driver != null)
driver.close();
});
test('inital tree creation', () async {
// Let app become fully idle.
await new Future<Null>.delayed(const Duration(seconds: 1));
final Timeline timeline = await driver.traceAction(() async {
expect(await driver.setSemantics(true), isTrue);
});
final Iterable<TimelineEvent> semanticsEvents = timeline.events.where((TimelineEvent event) => event.name == "Semantics");
if (semanticsEvents.length != 1)
fail('Expected exactly one semantics event, got ${semanticsEvents.length}');
final Duration semanticsTreeCreation = semanticsEvents.first.duration;
final String json = JSON.encode(<String, dynamic>{'initialSemanticsTreeCreation': semanticsTreeCreation.inMilliseconds});
new File(p.join(testOutputsDirectory, 'complex_layout_semantics_perf.json')).writeAsStringSync(json);
});
});
}

View File

@@ -0,0 +1,38 @@
// Copyright (c) 2017 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 'package:flutter_devicelab/framework/adb.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/utils.dart';
import 'package:path/path.dart' as p;
void main() {
task(() async {
deviceOperatingSystem = DeviceOperatingSystem.android;
final Device device = await devices.workingDevice;
await device.unlock();
final String deviceId = device.deviceId;
await flutter('packages', options: <String>['get']);
final String complexLayoutPath = p.join(flutterDirectory.path, 'dev', 'benchmarks', 'complex_layout');
await inDirectory(complexLayoutPath, () async {
await flutter('drive', options: <String>[
'-v',
'--profile',
'--trace-startup', // Enables "endless" timeline event buffering.
'-t',
p.join(complexLayoutPath, 'test_driver', 'semantics_perf.dart'),
'-d',
deviceId,
]);
});
final String dataPath = p.join(complexLayoutPath, 'build', 'complex_layout_semantics_perf.json');
return new TaskResult.successFromFile(file(dataPath), benchmarkScoreKeys: <String>[
'initialSemanticsTreeCreation',
]);
});
}

View File

@@ -133,6 +133,13 @@ tasks:
required_agent_capabilities: ["linux/android"]
flaky: true
complex_layout_semantics_perf:
description: >
Measures duration of building the initial semantics tree.
stage: devicelab
required_agent_capabilities: ["linux/android"]
flaky: true
# iOS on-device tests
channels_integration_test_ios: