Unverified Commit d030296a authored by Dan Field's avatar Dan Field Committed by GitHub

Reland test (#50987)

parent 2ce51aa2
......@@ -10,3 +10,4 @@ const String kSimpleAnimationRouteName = '/simple_animation';
const String kPictureCacheRouteName = '/picture_cache';
const String kLargeImagesRouteName = '/large_images';
const String kTextRouteName = '/text';
const String kAnimatedPlaceholderRouteName = '/animated_placeholder';
......@@ -7,6 +7,7 @@ import 'package:macrobenchmarks/src/large_images.dart';
import 'package:macrobenchmarks/src/picture_cache.dart';
import 'common.dart';
import 'src/animated_placeholder.dart';
import 'src/backdrop_filter.dart';
import 'src/cubic_bezier.dart';
import 'src/cull_opacity.dart';
......@@ -14,7 +15,7 @@ import 'src/post_backdrop_filter.dart';
import 'src/simple_animation.dart';
import 'src/text.dart';
const String kMacrobenchmarks ='Macrobenchmarks';
const String kMacrobenchmarks = 'Macrobenchmarks';
void main() => runApp(const MacrobenchmarksApp());
......@@ -36,6 +37,7 @@ class MacrobenchmarksApp extends StatelessWidget {
kPictureCacheRouteName: (BuildContext context) => PictureCachePage(),
kLargeImagesRouteName: (BuildContext context) => LargeImagesPage(),
kTextRouteName: (BuildContext context) => TextPage(),
kAnimatedPlaceholderRouteName: (BuildContext context) => AnimatedPlaceholderPage(),
},
);
}
......@@ -106,6 +108,13 @@ class HomePage extends StatelessWidget {
Navigator.pushNamed(context, kTextRouteName);
},
),
RaisedButton(
key: const Key(kAnimatedPlaceholderRouteName),
child: const Text('Animated Placeholder'),
onPressed: () {
Navigator.pushNamed(context, kAnimatedPlaceholderRouteName);
},
),
],
),
);
......
// Copyright 2014 The Flutter 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:ui' as ui show Codec;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
/// An animated GIF image with 3 1x1 pixel frames (a red, green, and blue
/// frames). The GIF animates forever, and each frame has a 100ms delay.
const String kAnimatedGif = 'R0lGODlhAQABAKEDAAAA//8AAAD/AP///yH/C05FVFNDQVBFMi'
'4wAwEAAAAh+QQACgD/ACwAAAAAAQABAAACAkwBACH5BAAKAP8A'
'LAAAAAABAAEAAAICVAEAIfkEAAoA/wAsAAAAAAEAAQAAAgJEAQ'
'A7';
/// A 50x50 blue square png
const String kBlueSquare = 'iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAASEl'
'EQVR42u3PMQ0AMAgAsGFjL/4tYQU08JLWQSN/9TsgRERERERERE'
'REREREREREREREREREREREREREREREREREREREREQ2BgNuaUcSj'
'uqqAAAAAElFTkSuQmCC';
/// A 10x10 grid of animated looping placeholder gifts that fade into a
/// blue square.
class AnimatedPlaceholderPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GridView.builder(
itemCount: 100,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 10),
itemBuilder: (BuildContext context, int index) {
return FadeInImage(
placeholder: DelayedBase64Image(Duration.zero, kAnimatedGif),
image: DelayedBase64Image(Duration(milliseconds: 100 * index), kBlueSquare),
);
},
);
}
}
int _key = 0;
/// An image provider that is always unique from other DelayedBase64Images and
/// simulates a delay in loading.
class DelayedBase64Image extends ImageProvider<int> {
const DelayedBase64Image(this.delay, this.data);
final String data;
final Duration delay;
@override
Future<int> obtainKey(ImageConfiguration configuration) {
return SynchronousFuture<int>(_key++);
}
@override
ImageStreamCompleter load(int key, DecoderCallback decode) {
return MultiFrameImageStreamCompleter(
codec: Future<ui.Codec>.delayed(
delay,
() => decode(base64.decode(data)),
),
scale: 1.0,
);
}
}
// Copyright 2014 The Flutter 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:macrobenchmarks/main.dart' as app;
void main() {
enableFlutterDriverExtension();
app.main();
}
// Copyright 2014 The Flutter 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:macrobenchmarks/common.dart';
import 'util.dart';
void main() {
macroPerfTest(
'animated_placeholder_perf',
kAnimatedPlaceholderRouteName,
pageDelay: const Duration(seconds: 1),
duration: const Duration(seconds: 15),
);
}
// Copyright 2014 The Flutter 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/tasks/perf_tests.dart';
Future<void> main() async {
deviceOperatingSystem = DeviceOperatingSystem.android;
await task(createAnimatedPlaceholderPerfTest());
}
......@@ -81,6 +81,15 @@ TaskFunction createSimpleAnimationPerfTest({bool needsMeasureCpuGpu = false}) {
).run;
}
TaskFunction createAnimatedPlaceholderPerfTest({bool needsMeasureCpuGpu = false}) {
return PerfTest(
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
'test_driver/animated_placeholder_perf.dart',
'animated_placeholder_perf',
needsMeasureCpuGPu: needsMeasureCpuGpu,
).run;
}
TaskFunction createPictureCachePerfTest() {
return PerfTest(
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
......
......@@ -700,6 +700,15 @@ tasks:
stage: devicelab
required_agent_capabilities: ["mac/android"]
animated_placeholder_perf:
description: >
Measures frame build and rasterizer times, as well as frame build counts
for a grid of images that uses FadeInImage with an animated gif as the
placeholder.
stage: devicelab
required_agent_capabilities: ["linux/android"]
flaky: true
analyzer_benchmark:
description: >
Measures the speed of Dart analyzer.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment