blob: c64aa3137d478576fc4cb506902b3d1562e9012a [file] [log] [blame]
// Copyright 2019 The Fuchsia 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:sl4f/sl4f.dart';
import 'package:sl4f/trace_processing.dart';
import 'package:test/test.dart';
import 'helpers.dart';
const String _catapultConverterPath = 'runtime_deps/catapult_converter';
const String _trace2jsonPath = 'runtime_deps/trace2json';
Future<void> _killProcesses(PerfTestHelper helper) async {
await'killall "root_presenter*"');
await'killall "scenic*"');
await'killall "basemgr*"');
await'killall "flutter*"');
await'killall "present_view*"');
await'killall "simplest_app*"');
void _addTest(String testName, String runAppCommand) {
test(testName, () async {
final helper = await PerfTestHelper.make();
await _killProcesses(helper);
final runApp =;
// Wait for the application to start.
await Future.delayed(Duration(seconds: 3));
// Start tracing.
final traceSession = await helper.performance.initializeTracing(
categories: ['input', 'gfx', 'magma'], bufferSize: 36);
await traceSession.start();
// Each tap will be 33.5ms apart, drifting 0.166ms against regular 60 fps
// vsync interval. 100 taps span the entire vsync interval 1 time at 100
// equidistant points.
await helper.sl4fDriver.ssh
.run('/bin/input tap 500 500 --tap_event_count=100 --duration=3350');
await traceSession.stop();
final fxtTraceFile = await traceSession.terminateAndDownload(testName);
final jsonTraceFile = await helper.performance
.convertTraceFileToJson(_trace2jsonPath, fxtTraceFile);
final metricsSpecSet = MetricsSpecSet(
testName: testName,
metricsSpecs: [
MetricsSpec(name: 'input_latency'),
await helper.performance.processTrace(metricsSpecSet, jsonTraceFile,
converterPath: _catapultConverterPath),
// Clean up by killing the processes. The reason for this is that we want
// to prevent these processes from interfering with later performance
// tests.
await _killProcesses(helper);
await runApp;
void main() {
'/bin/run -d fuchsia-pkg://');
'/bin/present_view '
'fuchsia-pkg:// '
'--NV12 --input_driven');