Migrate dev/benchmarks/macrobenchmarks to null safety. (#85501)
This commit is contained in:
@@ -52,7 +52,7 @@ class BenchBuildImage extends WidgetRecorder {
|
||||
}
|
||||
|
||||
class _RotatingWidget extends StatefulWidget {
|
||||
const _RotatingWidget({this.child, Key key}) : super(key: key);
|
||||
const _RotatingWidget({required this.child, Key? key}) : super(key: key);
|
||||
|
||||
final Widget child;
|
||||
|
||||
@@ -61,7 +61,7 @@ class _RotatingWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _RotatingWidgetState extends State<_RotatingWidget> with SingleTickerProviderStateMixin {
|
||||
AnimationController controller;
|
||||
late AnimationController controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -72,11 +72,17 @@ class _RotatingWidgetState extends State<_RotatingWidget> with SingleTickerProvi
|
||||
)..repeat();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (BuildContext context, Widget child) {
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return Transform(
|
||||
transform: Matrix4.identity()..rotateZ(2 * math.pi * controller.value),
|
||||
child: widget.child,
|
||||
@@ -84,5 +90,4 @@ class _RotatingWidgetState extends State<_RotatingWidget> with SingleTickerProvi
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
|
||||
|
||||
static const String benchmarkName = 'build_material_checkbox';
|
||||
|
||||
static bool _isChecked;
|
||||
static bool? _isChecked;
|
||||
|
||||
@override
|
||||
Widget createWidget() {
|
||||
@@ -33,7 +33,7 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
|
||||
Row _buildRow() {
|
||||
if (_isChecked == null) {
|
||||
_isChecked = true;
|
||||
} else if (_isChecked) {
|
||||
} else if (_isChecked!) {
|
||||
_isChecked = false;
|
||||
} else {
|
||||
_isChecked = null;
|
||||
@@ -45,7 +45,7 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
|
||||
child: Checkbox(
|
||||
value: _isChecked,
|
||||
tristate: true,
|
||||
onChanged: (bool newValue) {
|
||||
onChanged: (bool? newValue) {
|
||||
// Intentionally empty.
|
||||
},
|
||||
),
|
||||
|
||||
@@ -35,7 +35,7 @@ class BenchCardInfiniteScroll extends WidgetRecorder {
|
||||
}
|
||||
|
||||
class _InfiniteScrollCards extends StatefulWidget {
|
||||
const _InfiniteScrollCards(this.initialOffset, this.finalOffset, {Key key}) : super(key: key);
|
||||
const _InfiniteScrollCards(this.initialOffset, this.finalOffset, {Key? key}) : super(key: key);
|
||||
|
||||
final double initialOffset;
|
||||
final double finalOffset;
|
||||
@@ -47,8 +47,8 @@ class _InfiniteScrollCards extends StatefulWidget {
|
||||
class _InfiniteScrollCardsState extends State<_InfiniteScrollCards> {
|
||||
static const Duration stepDuration = Duration(seconds: 20);
|
||||
|
||||
ScrollController scrollController;
|
||||
double offset;
|
||||
late ScrollController scrollController;
|
||||
late double offset;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -70,6 +70,12 @@ class _InfiniteScrollCardsState extends State<_InfiniteScrollCards> {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
|
||||
@@ -31,10 +31,10 @@ class BenchUpdateManyChildLayers extends SceneBuilderRecorder {
|
||||
/// is correctly pumping frames.
|
||||
double wobbleCounter = 0;
|
||||
|
||||
List<Picture> _pictures;
|
||||
Size windowSize;
|
||||
Size cellSize;
|
||||
Size rectSize;
|
||||
late List<Picture> _pictures;
|
||||
late Size windowSize;
|
||||
late Size cellSize;
|
||||
late Size rectSize;
|
||||
|
||||
@override
|
||||
Future<void> setUpAll() async {
|
||||
@@ -55,7 +55,7 @@ class BenchUpdateManyChildLayers extends SceneBuilderRecorder {
|
||||
}
|
||||
}
|
||||
|
||||
OffsetEngineLayer _rootLayer;
|
||||
OffsetEngineLayer? _rootLayer;
|
||||
final Map<int, OffsetEngineLayer> _layers = <int, OffsetEngineLayer>{};
|
||||
|
||||
@override
|
||||
@@ -64,7 +64,7 @@ class BenchUpdateManyChildLayers extends SceneBuilderRecorder {
|
||||
for (int row = 0; row < kRows; row++) {
|
||||
for (int col = 0; col < kColumns; col++) {
|
||||
final int layerId = 1000000 * row + col;
|
||||
final OffsetEngineLayer oldLayer = _layers[layerId];
|
||||
final OffsetEngineLayer? oldLayer = _layers[layerId];
|
||||
final double wobbleOffsetX = col * cellSize.width + (wobbleCounter - 5).abs();
|
||||
final double offsetY = row * cellSize.height;
|
||||
// Retain every other layer, so we exercise the update path 50% of the
|
||||
|
||||
@@ -93,9 +93,9 @@ class BenchDynamicClipOnStaticPicture extends SceneBuilderRecorder {
|
||||
|
||||
static const String benchmarkName = 'dynamic_clip_on_static_picture';
|
||||
|
||||
Size screenSize;
|
||||
Size clipSize;
|
||||
Picture picture;
|
||||
late Size screenSize;
|
||||
late Size clipSize;
|
||||
late Picture picture;
|
||||
double pictureVerticalOffset = 0.0;
|
||||
|
||||
@override
|
||||
|
||||
@@ -14,7 +14,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'recorder.dart';
|
||||
|
||||
class _NestedMouseRegion extends StatelessWidget {
|
||||
const _NestedMouseRegion({this.nests, this.child});
|
||||
const _NestedMouseRegion({required this.nests, required this.child});
|
||||
|
||||
final int nests;
|
||||
final Widget child;
|
||||
@@ -42,10 +42,10 @@ class BenchMouseRegionGridHover extends WidgetRecorder {
|
||||
|
||||
static const String benchmarkName = 'bench_mouse_region_grid_hover';
|
||||
|
||||
_Tester _tester;
|
||||
late _Tester _tester;
|
||||
|
||||
void handleDataPoint(Duration duration) {
|
||||
profile.addDataPoint('hitTestDuration', duration, reported: true);
|
||||
profile!.addDataPoint('hitTestDuration', duration, reported: true);
|
||||
}
|
||||
|
||||
// Use a non-trivial border to force Web to switch painter
|
||||
@@ -66,7 +66,7 @@ class BenchMouseRegionGridHover extends WidgetRecorder {
|
||||
void frameDidDraw() {
|
||||
if (!started) {
|
||||
started = true;
|
||||
SchedulerBinding.instance.addPostFrameCallback((Duration timeStamp) async {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((Duration timeStamp) async {
|
||||
_tester.start();
|
||||
registerDidStop(_tester.stop);
|
||||
});
|
||||
@@ -119,22 +119,22 @@ class BenchMouseRegionGridHover extends WidgetRecorder {
|
||||
class _UntilNextFrame {
|
||||
_UntilNextFrame._();
|
||||
|
||||
static Completer<void> _completer;
|
||||
static Completer<void>? _completer;
|
||||
|
||||
static Future<void> wait() {
|
||||
if (_UntilNextFrame._completer == null) {
|
||||
_UntilNextFrame._completer = Completer<void>();
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
_UntilNextFrame._completer.complete(null);
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
_UntilNextFrame._completer!.complete(null);
|
||||
_UntilNextFrame._completer = null;
|
||||
});
|
||||
}
|
||||
return _UntilNextFrame._completer.future;
|
||||
return _UntilNextFrame._completer!.future;
|
||||
}
|
||||
}
|
||||
|
||||
class _Tester {
|
||||
_Tester({this.onDataPoint});
|
||||
_Tester({required this.onDataPoint});
|
||||
|
||||
final ValueSetter<Duration> onDataPoint;
|
||||
|
||||
@@ -145,12 +145,12 @@ class _Tester {
|
||||
TestGesture get gesture {
|
||||
return _gesture ??= TestGesture(
|
||||
dispatcher: (PointerEvent event) async {
|
||||
RendererBinding.instance.handlePointerEvent(event);
|
||||
RendererBinding.instance!.handlePointerEvent(event);
|
||||
},
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
}
|
||||
TestGesture _gesture;
|
||||
TestGesture? _gesture;
|
||||
|
||||
Duration currentTime = Duration.zero;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class BenchMouseRegionGridScroll extends WidgetRecorder {
|
||||
void frameDidDraw() {
|
||||
if (!started) {
|
||||
started = true;
|
||||
SchedulerBinding.instance.addPostFrameCallback((Duration timeStamp) async {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((Duration timeStamp) async {
|
||||
_tester.start();
|
||||
registerDidStop(_tester.stop);
|
||||
});
|
||||
@@ -91,17 +91,17 @@ class BenchMouseRegionGridScroll extends WidgetRecorder {
|
||||
class _UntilNextFrame {
|
||||
_UntilNextFrame._();
|
||||
|
||||
static Completer<void> _completer;
|
||||
static Completer<void>? _completer;
|
||||
|
||||
static Future<void> wait() {
|
||||
if (_UntilNextFrame._completer == null) {
|
||||
_UntilNextFrame._completer = Completer<void>();
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
_UntilNextFrame._completer.complete(null);
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
_UntilNextFrame._completer!.complete(null);
|
||||
_UntilNextFrame._completer = null;
|
||||
});
|
||||
}
|
||||
return _UntilNextFrame._completer.future;
|
||||
return _UntilNextFrame._completer!.future;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,12 +117,12 @@ class _Tester {
|
||||
TestGesture get gesture {
|
||||
return _gesture ??= TestGesture(
|
||||
dispatcher: (PointerEvent event) async {
|
||||
RendererBinding.instance.handlePointerEvent(event);
|
||||
RendererBinding.instance!.handlePointerEvent(event);
|
||||
},
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
}
|
||||
TestGesture _gesture;
|
||||
TestGesture? _gesture;
|
||||
|
||||
Duration currentTime = Duration.zero;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'recorder.dart';
|
||||
|
||||
class _NestedMouseRegion extends StatelessWidget {
|
||||
const _NestedMouseRegion({this.nests, this.child});
|
||||
const _NestedMouseRegion({required this.nests, required this.child});
|
||||
|
||||
final int nests;
|
||||
final Widget child;
|
||||
@@ -33,7 +33,7 @@ class _NestedMouseRegion extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _NestedListener extends StatelessWidget {
|
||||
const _NestedListener({this.nests, this.child});
|
||||
const _NestedListener({required this.nests, required this.child});
|
||||
|
||||
final int nests;
|
||||
final Widget child;
|
||||
@@ -61,10 +61,10 @@ class BenchMouseRegionMixedGridHover extends WidgetRecorder {
|
||||
|
||||
static const String benchmarkName = 'bench_mouse_region_mixed_grid_hover';
|
||||
|
||||
_Tester _tester;
|
||||
late _Tester _tester;
|
||||
|
||||
void handleDataPoint(Duration duration) {
|
||||
profile.addDataPoint('hitTestDuration', duration, reported: true);
|
||||
profile!.addDataPoint('hitTestDuration', duration, reported: true);
|
||||
}
|
||||
|
||||
// Use a non-trivial border to force Web to switch painter
|
||||
@@ -85,7 +85,7 @@ class BenchMouseRegionMixedGridHover extends WidgetRecorder {
|
||||
void frameDidDraw() {
|
||||
if (!started) {
|
||||
started = true;
|
||||
SchedulerBinding.instance.addPostFrameCallback((Duration timeStamp) async {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((Duration timeStamp) async {
|
||||
_tester.start();
|
||||
registerDidStop(_tester.stop);
|
||||
});
|
||||
@@ -141,22 +141,22 @@ class BenchMouseRegionMixedGridHover extends WidgetRecorder {
|
||||
class _UntilNextFrame {
|
||||
_UntilNextFrame._();
|
||||
|
||||
static Completer<void> _completer;
|
||||
static Completer<void>? _completer;
|
||||
|
||||
static Future<void> wait() {
|
||||
if (_UntilNextFrame._completer == null) {
|
||||
_UntilNextFrame._completer = Completer<void>();
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
_UntilNextFrame._completer.complete(null);
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
_UntilNextFrame._completer!.complete(null);
|
||||
_UntilNextFrame._completer = null;
|
||||
});
|
||||
}
|
||||
return _UntilNextFrame._completer.future;
|
||||
return _UntilNextFrame._completer!.future;
|
||||
}
|
||||
}
|
||||
|
||||
class _Tester {
|
||||
_Tester({this.onDataPoint});
|
||||
_Tester({required this.onDataPoint});
|
||||
|
||||
final ValueSetter<Duration> onDataPoint;
|
||||
|
||||
@@ -167,12 +167,12 @@ class _Tester {
|
||||
TestGesture get gesture {
|
||||
return _gesture ??= TestGesture(
|
||||
dispatcher: (PointerEvent event) async {
|
||||
RendererBinding.instance.handlePointerEvent(event);
|
||||
RendererBinding.instance!.handlePointerEvent(event);
|
||||
},
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
}
|
||||
TestGesture _gesture;
|
||||
TestGesture? _gesture;
|
||||
|
||||
Duration currentTime = Duration.zero;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class BenchPageViewScrollLineThrough extends WidgetRecorder {
|
||||
}
|
||||
|
||||
class _MyScrollContainer extends StatefulWidget {
|
||||
const _MyScrollContainer({Key key}) : super(key: key);
|
||||
const _MyScrollContainer({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<_MyScrollContainer> createState() => _MyScrollContainerState();
|
||||
@@ -35,7 +35,7 @@ class _MyScrollContainer extends StatefulWidget {
|
||||
class _MyScrollContainerState extends State<_MyScrollContainer> {
|
||||
static const Duration stepDuration = Duration(milliseconds: 500);
|
||||
|
||||
PageController pageController;
|
||||
late PageController pageController;
|
||||
int pageNumber = 0;
|
||||
|
||||
@override
|
||||
@@ -56,8 +56,8 @@ class _MyScrollContainerState extends State<_MyScrollContainer> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
pageController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -77,8 +77,8 @@ class _CustomPainter extends CustomPainter {
|
||||
_CustomPainter(this.text);
|
||||
|
||||
final String text;
|
||||
Paint _linePainter;
|
||||
TextPainter _textPainter;
|
||||
final Paint _linePainter = Paint();
|
||||
final TextPainter _textPainter = TextPainter();
|
||||
static const double lineWidth = 0.5;
|
||||
|
||||
@override
|
||||
@@ -91,14 +91,12 @@ class _CustomPainter extends CustomPainter {
|
||||
const double viewPadding = 5;
|
||||
const double circlePadding = 4;
|
||||
yPosition = viewPadding;
|
||||
_textPainter = _textPainter ?? TextPainter();
|
||||
_textPainter.textDirection = TextDirection.ltr;
|
||||
_textPainter.textWidthBasis = TextWidthBasis.longestLine;
|
||||
_textPainter.textScaleFactor = 1;
|
||||
const TextStyle textStyle =
|
||||
TextStyle(color: Colors.black87, fontSize: 13, fontFamily: 'Roboto');
|
||||
|
||||
_linePainter = _linePainter ?? Paint();
|
||||
_linePainter.isAntiAlias = true;
|
||||
for (int i = 0; i < 42; i++) {
|
||||
_linePainter.color = Colors.white;
|
||||
|
||||
@@ -7,218 +7,218 @@ import 'dart:ui';
|
||||
// The code below was generated by modify several parts of the engine
|
||||
// May 2020 and running Flutter Gallery.
|
||||
|
||||
PathFillType gFillType;
|
||||
Rect gBounds;
|
||||
List<dynamic> allPaths;
|
||||
late PathFillType gFillType;
|
||||
late Rect gBounds;
|
||||
late List<dynamic> allPaths;
|
||||
|
||||
Path path8;
|
||||
Path path10;
|
||||
Path path12;
|
||||
Path path14;
|
||||
Path path16;
|
||||
Path path18;
|
||||
Path path34;
|
||||
Path path50;
|
||||
Path path60;
|
||||
Path path63;
|
||||
Path path66;
|
||||
Path path69;
|
||||
Path path72;
|
||||
Path path75;
|
||||
Path path78;
|
||||
Path path80;
|
||||
Path path82;
|
||||
Path path84;
|
||||
Path path86;
|
||||
Path path88;
|
||||
Path path119;
|
||||
Path path120;
|
||||
Path path121;
|
||||
Path path122;
|
||||
Path path123;
|
||||
Path path125;
|
||||
Path path127;
|
||||
Path path129;
|
||||
Path path131;
|
||||
Path path132;
|
||||
Path path134;
|
||||
Path path137;
|
||||
Path path140;
|
||||
Path path143;
|
||||
Path path145;
|
||||
Path path147;
|
||||
Path path208;
|
||||
Path path209;
|
||||
Path path210;
|
||||
Path path211;
|
||||
Path path213;
|
||||
Path path216;
|
||||
Path path219;
|
||||
Path path222;
|
||||
Path path225;
|
||||
Path path227;
|
||||
Path path229;
|
||||
Path path232;
|
||||
Path path235;
|
||||
Path path238;
|
||||
Path path240;
|
||||
Path path242;
|
||||
Path path277;
|
||||
Path path278;
|
||||
Path path279;
|
||||
Path path280;
|
||||
Path path281;
|
||||
Path path282;
|
||||
Path path284;
|
||||
Path path286;
|
||||
Path path288;
|
||||
Path path290;
|
||||
Path path292;
|
||||
Path path295;
|
||||
Path path298;
|
||||
Path path301;
|
||||
Path path330;
|
||||
Path path331;
|
||||
Path path332;
|
||||
Path path333;
|
||||
Path path334;
|
||||
Path path336;
|
||||
Path path338;
|
||||
Path path340;
|
||||
Path path342;
|
||||
Path path344;
|
||||
Path path345;
|
||||
Path path346;
|
||||
Path path349;
|
||||
Path path352;
|
||||
Path path356;
|
||||
Path path358;
|
||||
Path path359;
|
||||
Path path360;
|
||||
Path path361;
|
||||
Path path362;
|
||||
Path path363;
|
||||
Path path366;
|
||||
Path path369;
|
||||
Path path372;
|
||||
Path path373;
|
||||
Path path374;
|
||||
Path path375;
|
||||
Path path376;
|
||||
Path path379;
|
||||
Path path382;
|
||||
Path path385;
|
||||
Path path386;
|
||||
Path path387;
|
||||
Path path388;
|
||||
Path path389;
|
||||
Path path392;
|
||||
Path path395;
|
||||
Path path398;
|
||||
Path path399;
|
||||
Path path400;
|
||||
Path path401;
|
||||
Path path402;
|
||||
Path path405;
|
||||
Path path408;
|
||||
Path path411;
|
||||
Path path412;
|
||||
Path path413;
|
||||
Path path414;
|
||||
Path path415;
|
||||
Path path418;
|
||||
Path path421;
|
||||
Path path424;
|
||||
Path path425;
|
||||
Path path426;
|
||||
Path path427;
|
||||
Path path428;
|
||||
Path path431;
|
||||
Path path434;
|
||||
Path path437;
|
||||
Path path438;
|
||||
Path path439;
|
||||
Path path440;
|
||||
Path path441;
|
||||
Path path444;
|
||||
Path path447;
|
||||
Path path450;
|
||||
Path path451;
|
||||
Path path452;
|
||||
Path path453;
|
||||
Path path454;
|
||||
Path path457;
|
||||
Path path460;
|
||||
Path path463;
|
||||
Path path464;
|
||||
Path path465;
|
||||
Path path466;
|
||||
Path path467;
|
||||
Path path470;
|
||||
Path path473;
|
||||
Path path476;
|
||||
Path path477;
|
||||
Path path478;
|
||||
Path path479;
|
||||
Path path480;
|
||||
Path path483;
|
||||
Path path486;
|
||||
Path path489;
|
||||
Path path490;
|
||||
Path path491;
|
||||
Path path492;
|
||||
Path path493;
|
||||
Path path496;
|
||||
Path path499;
|
||||
Path path502;
|
||||
Path path503;
|
||||
Path path504;
|
||||
Path path505;
|
||||
Path path506;
|
||||
Path path509;
|
||||
Path path512;
|
||||
Path path515;
|
||||
Path path516;
|
||||
Path path517;
|
||||
Path path518;
|
||||
Path path519;
|
||||
Path path522;
|
||||
Path path525;
|
||||
Path path528;
|
||||
Path path529;
|
||||
Path path530;
|
||||
Path path531;
|
||||
Path path532;
|
||||
Path path535;
|
||||
Path path538;
|
||||
Path path541;
|
||||
Path path542;
|
||||
Path path543;
|
||||
Path path544;
|
||||
Path path545;
|
||||
Path path548;
|
||||
Path path551;
|
||||
Path path554;
|
||||
Path path555;
|
||||
Path path556;
|
||||
Path path557;
|
||||
Path path558;
|
||||
Path path561;
|
||||
Path path564;
|
||||
Path path573;
|
||||
Path path577;
|
||||
Path path579;
|
||||
Path path591;
|
||||
Path path592;
|
||||
Path path593;
|
||||
Path path594;
|
||||
Path path595;
|
||||
Path path597;
|
||||
Path path599;
|
||||
Path path601;
|
||||
Path path603;
|
||||
Path path606;
|
||||
Path path608;
|
||||
late Path path8;
|
||||
late Path path10;
|
||||
late Path path12;
|
||||
late Path path14;
|
||||
late Path path16;
|
||||
late Path path18;
|
||||
late Path path34;
|
||||
late Path path50;
|
||||
late Path path60;
|
||||
late Path path63;
|
||||
late Path path66;
|
||||
late Path path69;
|
||||
late Path path72;
|
||||
late Path path75;
|
||||
late Path path78;
|
||||
late Path path80;
|
||||
late Path path82;
|
||||
late Path path84;
|
||||
late Path path86;
|
||||
late Path path88;
|
||||
late Path path119;
|
||||
late Path path120;
|
||||
late Path path121;
|
||||
late Path path122;
|
||||
late Path path123;
|
||||
late Path path125;
|
||||
late Path path127;
|
||||
late Path path129;
|
||||
late Path path131;
|
||||
late Path path132;
|
||||
late Path path134;
|
||||
late Path path137;
|
||||
late Path path140;
|
||||
late Path path143;
|
||||
late Path path145;
|
||||
late Path path147;
|
||||
late Path path208;
|
||||
late Path path209;
|
||||
late Path path210;
|
||||
late Path path211;
|
||||
late Path path213;
|
||||
late Path path216;
|
||||
late Path path219;
|
||||
late Path path222;
|
||||
late Path path225;
|
||||
late Path path227;
|
||||
late Path path229;
|
||||
late Path path232;
|
||||
late Path path235;
|
||||
late Path path238;
|
||||
late Path path240;
|
||||
late Path path242;
|
||||
late Path path277;
|
||||
late Path path278;
|
||||
late Path path279;
|
||||
late Path path280;
|
||||
late Path path281;
|
||||
late Path path282;
|
||||
late Path path284;
|
||||
late Path path286;
|
||||
late Path path288;
|
||||
late Path path290;
|
||||
late Path path292;
|
||||
late Path path295;
|
||||
late Path path298;
|
||||
late Path path301;
|
||||
late Path path330;
|
||||
late Path path331;
|
||||
late Path path332;
|
||||
late Path path333;
|
||||
late Path path334;
|
||||
late Path path336;
|
||||
late Path path338;
|
||||
late Path path340;
|
||||
late Path path342;
|
||||
late Path path344;
|
||||
late Path path345;
|
||||
late Path path346;
|
||||
late Path path349;
|
||||
late Path path352;
|
||||
late Path path356;
|
||||
late Path path358;
|
||||
late Path path359;
|
||||
late Path path360;
|
||||
late Path path361;
|
||||
late Path path362;
|
||||
late Path path363;
|
||||
late Path path366;
|
||||
late Path path369;
|
||||
late Path path372;
|
||||
late Path path373;
|
||||
late Path path374;
|
||||
late Path path375;
|
||||
late Path path376;
|
||||
late Path path379;
|
||||
late Path path382;
|
||||
late Path path385;
|
||||
late Path path386;
|
||||
late Path path387;
|
||||
late Path path388;
|
||||
late Path path389;
|
||||
late Path path392;
|
||||
late Path path395;
|
||||
late Path path398;
|
||||
late Path path399;
|
||||
late Path path400;
|
||||
late Path path401;
|
||||
late Path path402;
|
||||
late Path path405;
|
||||
late Path path408;
|
||||
late Path path411;
|
||||
late Path path412;
|
||||
late Path path413;
|
||||
late Path path414;
|
||||
late Path path415;
|
||||
late Path path418;
|
||||
late Path path421;
|
||||
late Path path424;
|
||||
late Path path425;
|
||||
late Path path426;
|
||||
late Path path427;
|
||||
late Path path428;
|
||||
late Path path431;
|
||||
late Path path434;
|
||||
late Path path437;
|
||||
late Path path438;
|
||||
late Path path439;
|
||||
late Path path440;
|
||||
late Path path441;
|
||||
late Path path444;
|
||||
late Path path447;
|
||||
late Path path450;
|
||||
late Path path451;
|
||||
late Path path452;
|
||||
late Path path453;
|
||||
late Path path454;
|
||||
late Path path457;
|
||||
late Path path460;
|
||||
late Path path463;
|
||||
late Path path464;
|
||||
late Path path465;
|
||||
late Path path466;
|
||||
late Path path467;
|
||||
late Path path470;
|
||||
late Path path473;
|
||||
late Path path476;
|
||||
late Path path477;
|
||||
late Path path478;
|
||||
late Path path479;
|
||||
late Path path480;
|
||||
late Path path483;
|
||||
late Path path486;
|
||||
late Path path489;
|
||||
late Path path490;
|
||||
late Path path491;
|
||||
late Path path492;
|
||||
late Path path493;
|
||||
late Path path496;
|
||||
late Path path499;
|
||||
late Path path502;
|
||||
late Path path503;
|
||||
late Path path504;
|
||||
late Path path505;
|
||||
late Path path506;
|
||||
late Path path509;
|
||||
late Path path512;
|
||||
late Path path515;
|
||||
late Path path516;
|
||||
late Path path517;
|
||||
late Path path518;
|
||||
late Path path519;
|
||||
late Path path522;
|
||||
late Path path525;
|
||||
late Path path528;
|
||||
late Path path529;
|
||||
late Path path530;
|
||||
late Path path531;
|
||||
late Path path532;
|
||||
late Path path535;
|
||||
late Path path538;
|
||||
late Path path541;
|
||||
late Path path542;
|
||||
late Path path543;
|
||||
late Path path544;
|
||||
late Path path545;
|
||||
late Path path548;
|
||||
late Path path551;
|
||||
late Path path554;
|
||||
late Path path555;
|
||||
late Path path556;
|
||||
late Path path557;
|
||||
late Path path558;
|
||||
late Path path561;
|
||||
late Path path564;
|
||||
late Path path573;
|
||||
late Path path577;
|
||||
late Path path579;
|
||||
late Path path591;
|
||||
late Path path592;
|
||||
late Path path593;
|
||||
late Path path594;
|
||||
late Path path595;
|
||||
late Path path597;
|
||||
late Path path599;
|
||||
late Path path601;
|
||||
late Path path603;
|
||||
late Path path606;
|
||||
late Path path608;
|
||||
|
||||
void createPaths() {
|
||||
allPaths = <dynamic>[];
|
||||
|
||||
@@ -26,12 +26,12 @@ class BenchPictureRecording extends RawRecorder {
|
||||
/// Cached paint used for drawing.
|
||||
///
|
||||
/// We want to avoid polluting the results with paint initialization logic.
|
||||
Paint paint;
|
||||
late Paint paint;
|
||||
|
||||
/// A prelaid out and cached paragraph.
|
||||
///
|
||||
/// This is cached to remove text layout time from the benchmark time.
|
||||
Paragraph paragraph;
|
||||
late Paragraph paragraph;
|
||||
|
||||
@override
|
||||
Future<void> setUpAll() async {
|
||||
|
||||
@@ -56,9 +56,9 @@ class BenchSimpleLazyTextScroll extends WidgetRecorder {
|
||||
|
||||
class _TestScrollingWidget extends StatefulWidget {
|
||||
const _TestScrollingWidget({
|
||||
@required this.initialScrollOffset,
|
||||
@required this.scrollDistance,
|
||||
@required this.scrollDuration,
|
||||
required this.initialScrollOffset,
|
||||
required this.scrollDistance,
|
||||
required this.scrollDuration,
|
||||
});
|
||||
|
||||
final double initialScrollOffset;
|
||||
@@ -72,7 +72,7 @@ class _TestScrollingWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _TestScrollingWidgetState extends State<_TestScrollingWidget> {
|
||||
ScrollController scrollController;
|
||||
late ScrollController scrollController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -98,6 +98,12 @@ class _TestScrollingWidgetState extends State<_TestScrollingWidget> {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
|
||||
@@ -31,7 +31,7 @@ class ParagraphGenerator {
|
||||
/// font-size so that the engine doesn't reuse a cached ruler.
|
||||
ui.Paragraph generate(
|
||||
String text, {
|
||||
int maxLines,
|
||||
int? maxLines,
|
||||
bool hasEllipsis = false,
|
||||
}) {
|
||||
final ui.ParagraphBuilder builder = ui.ParagraphBuilder(ui.ParagraphStyle(
|
||||
@@ -61,8 +61,8 @@ enum _TestMode {
|
||||
|
||||
/// Sends a platform message to the web engine to enable/disable the usage of
|
||||
/// the canvas-based text measurement implementation.
|
||||
void _setTestMode(_TestMode mode) {
|
||||
bool useCanvasText; // null means do not force DOM or canvas, works for CanvasKit
|
||||
void _setTestMode(_TestMode? mode) {
|
||||
bool? useCanvasText; // null means do not force DOM or canvas, works for CanvasKit
|
||||
switch (mode) {
|
||||
case _TestMode.useDomTextLayout:
|
||||
useCanvasText = false;
|
||||
@@ -148,11 +148,11 @@ class BenchTextLayout extends RawRecorder {
|
||||
}
|
||||
|
||||
void recordParagraphOperations({
|
||||
@required Profile profile,
|
||||
@required ui.Paragraph paragraph,
|
||||
@required String text,
|
||||
@required String keyPrefix,
|
||||
@required double maxWidth,
|
||||
required Profile profile,
|
||||
required ui.Paragraph paragraph,
|
||||
required String text,
|
||||
required String keyPrefix,
|
||||
required double maxWidth,
|
||||
}) {
|
||||
profile.record('$keyPrefix.layout', () {
|
||||
paragraph.layout(ui.ParagraphConstraints(width: maxWidth));
|
||||
@@ -277,7 +277,7 @@ class BenchBuildColorsGrid extends WidgetBuildRecorder {
|
||||
// updates the value of [showWidget] in preparation for the next frame.
|
||||
// TODO(yjbanov): https://github.com/flutter/flutter/issues/53877
|
||||
if (showWidget && _mode != _TestMode.useCanvasKit) {
|
||||
profile.addDataPoint(
|
||||
profile!.addDataPoint(
|
||||
'text_layout',
|
||||
Duration(microseconds: _textLayoutMicros.toInt()),
|
||||
reported: true,
|
||||
@@ -299,15 +299,13 @@ class BenchBuildColorsGrid extends WidgetBuildRecorder {
|
||||
const double kColorItemHeight = 48.0;
|
||||
|
||||
class Palette {
|
||||
Palette({this.name, this.primary, this.accent, this.threshold = 900});
|
||||
Palette({required this.name, required this.primary, this.accent, this.threshold = 900});
|
||||
|
||||
final String name;
|
||||
final MaterialColor primary;
|
||||
final MaterialAccentColor accent;
|
||||
final MaterialAccentColor? accent;
|
||||
final int
|
||||
threshold; // titles for indices > threshold are white, otherwise black
|
||||
|
||||
bool get isValid => name != null && primary != null && threshold != null;
|
||||
}
|
||||
|
||||
final List<Palette> allPalettes = <Palette>[
|
||||
@@ -390,9 +388,9 @@ final List<Palette> allPalettes = <Palette>[
|
||||
|
||||
class ColorItem extends StatelessWidget {
|
||||
const ColorItem({
|
||||
Key key,
|
||||
@required this.index,
|
||||
@required this.color,
|
||||
Key? key,
|
||||
required this.index,
|
||||
required this.color,
|
||||
this.prefix = '',
|
||||
}) : assert(index != null),
|
||||
assert(color != null),
|
||||
@@ -432,11 +430,10 @@ class ColorItem extends StatelessWidget {
|
||||
}
|
||||
|
||||
class PaletteTabView extends StatelessWidget {
|
||||
PaletteTabView({
|
||||
Key key,
|
||||
@required this.colors,
|
||||
}) : assert(colors != null && colors.isValid),
|
||||
super(key: key);
|
||||
const PaletteTabView({
|
||||
Key? key,
|
||||
required this.colors,
|
||||
}) : super(key: key);
|
||||
|
||||
final Palette colors;
|
||||
|
||||
@@ -458,9 +455,9 @@ class PaletteTabView extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final TextTheme textTheme = Theme.of(context).textTheme;
|
||||
final TextStyle whiteTextStyle =
|
||||
textTheme.bodyText2.copyWith(color: Colors.white);
|
||||
textTheme.bodyText2!.copyWith(color: Colors.white);
|
||||
final TextStyle blackTextStyle =
|
||||
textTheme.bodyText2.copyWith(color: Colors.black);
|
||||
textTheme.bodyText2!.copyWith(color: Colors.black);
|
||||
return Scrollbar(
|
||||
child: ListView(
|
||||
itemExtent: kColorItemHeight,
|
||||
@@ -468,7 +465,7 @@ class PaletteTabView extends StatelessWidget {
|
||||
...primaryKeys.map<Widget>((int index) {
|
||||
return DefaultTextStyle(
|
||||
style: index > colors.threshold ? whiteTextStyle : blackTextStyle,
|
||||
child: ColorItem(index: index, color: colors.primary[index]),
|
||||
child: ColorItem(index: index, color: colors.primary[index]!),
|
||||
);
|
||||
}),
|
||||
if (colors.accent != null)
|
||||
@@ -477,7 +474,7 @@ class PaletteTabView extends StatelessWidget {
|
||||
style:
|
||||
index > colors.threshold ? whiteTextStyle : blackTextStyle,
|
||||
child: ColorItem(
|
||||
index: index, color: colors.accent[index], prefix: 'A'),
|
||||
index: index, color: colors.accent![index]!, prefix: 'A'),
|
||||
);
|
||||
}),
|
||||
],
|
||||
@@ -487,7 +484,7 @@ class PaletteTabView extends StatelessWidget {
|
||||
}
|
||||
|
||||
class ColorsDemo extends StatelessWidget {
|
||||
const ColorsDemo({Key key}) : super(key: key);
|
||||
const ColorsDemo({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -54,8 +54,8 @@ class BenchTextOutOfPictureBounds extends SceneBuilderRecorder {
|
||||
|
||||
static const String benchmarkName = 'text_out_of_picture_bounds';
|
||||
|
||||
List<Paragraph> singleLineParagraphs;
|
||||
List<Paragraph> multiLineParagraphs;
|
||||
late List<Paragraph> singleLineParagraphs;
|
||||
late List<Paragraph> multiLineParagraphs;
|
||||
|
||||
@override
|
||||
void onDrawFrame(SceneBuilder sceneBuilder) {
|
||||
|
||||
@@ -29,16 +29,14 @@ class BenchWrapBoxScroll extends WidgetRecorder {
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({Key key, this.title}) : super(key: key);
|
||||
|
||||
final String title;
|
||||
const MyHomePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
ScrollController scrollController;
|
||||
late ScrollController scrollController;
|
||||
int block = 0;
|
||||
static const Duration stepDuration = Duration(milliseconds: 500);
|
||||
static const double stepDistance = 400;
|
||||
@@ -61,8 +59,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -84,7 +82,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
}
|
||||
|
||||
class ProductPreview extends StatelessWidget {
|
||||
const ProductPreview(this.previewIndex, {Key key}) : super(key: key);
|
||||
const ProductPreview(this.previewIndex, {Key? key}) : super(key: key);
|
||||
|
||||
final int previewIndex;
|
||||
|
||||
@@ -143,8 +141,8 @@ class ProductPreview extends StatelessWidget {
|
||||
|
||||
class ProductOption extends StatelessWidget {
|
||||
const ProductOption({
|
||||
Key key,
|
||||
@required this.optionText,
|
||||
Key? key,
|
||||
required this.optionText,
|
||||
}) : super(key: key);
|
||||
|
||||
final String optionText;
|
||||
|
||||
@@ -63,7 +63,7 @@ class Runner {
|
||||
///
|
||||
/// All arguments must not be null.
|
||||
Runner({
|
||||
@required this.recorder,
|
||||
required this.recorder,
|
||||
this.setUpAllDidRun = _dummyAsyncVoidCallback,
|
||||
this.tearDownAllWillRun = _dummyAsyncVoidCallback,
|
||||
});
|
||||
@@ -113,13 +113,13 @@ abstract class Recorder {
|
||||
/// Returns the recorded profile.
|
||||
///
|
||||
/// This value is only available while the benchmark is running.
|
||||
Profile get profile;
|
||||
Profile? get profile;
|
||||
|
||||
/// Whether the benchmark should continue running.
|
||||
///
|
||||
/// Returns `false` if the benchmark collected enough data and it's time to
|
||||
/// stop.
|
||||
bool shouldContinue() => profile.shouldContinue();
|
||||
bool shouldContinue() => profile?.shouldContinue() ?? true;
|
||||
|
||||
/// Called once before all runs of this benchmark recorder.
|
||||
///
|
||||
@@ -161,7 +161,7 @@ abstract class Recorder {
|
||||
/// }
|
||||
/// ```
|
||||
abstract class RawRecorder extends Recorder {
|
||||
RawRecorder({@required String name}) : super._(name, false);
|
||||
RawRecorder({required String name}) : super._(name, false);
|
||||
|
||||
/// The body of the benchmark.
|
||||
///
|
||||
@@ -169,8 +169,8 @@ abstract class RawRecorder extends Recorder {
|
||||
void body(Profile profile);
|
||||
|
||||
@override
|
||||
Profile get profile => _profile;
|
||||
Profile _profile;
|
||||
Profile? get profile => _profile;
|
||||
Profile? _profile;
|
||||
|
||||
@override
|
||||
@nonVirtual
|
||||
@@ -178,9 +178,9 @@ abstract class RawRecorder extends Recorder {
|
||||
_profile = Profile(name: name);
|
||||
do {
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
body(_profile);
|
||||
body(_profile!);
|
||||
} while (shouldContinue());
|
||||
return _profile;
|
||||
return _profile!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,11 +210,11 @@ abstract class RawRecorder extends Recorder {
|
||||
/// }
|
||||
/// ```
|
||||
abstract class SceneBuilderRecorder extends Recorder {
|
||||
SceneBuilderRecorder({@required String name}) : super._(name, true);
|
||||
SceneBuilderRecorder({required String name}) : super._(name, true);
|
||||
|
||||
@override
|
||||
Profile get profile => _profile;
|
||||
Profile _profile;
|
||||
Profile? get profile => _profile;
|
||||
Profile? _profile;
|
||||
|
||||
/// Called from [dart:ui.PlatformDispatcher.onBeginFrame].
|
||||
@mustCallSuper
|
||||
@@ -235,7 +235,7 @@ abstract class SceneBuilderRecorder extends Recorder {
|
||||
|
||||
window.onBeginFrame = (_) {
|
||||
try {
|
||||
startMeasureFrame(profile);
|
||||
startMeasureFrame(profile!);
|
||||
onBeginFrame();
|
||||
} catch (error, stackTrace) {
|
||||
profileCompleter.completeError(error, stackTrace);
|
||||
@@ -244,12 +244,12 @@ abstract class SceneBuilderRecorder extends Recorder {
|
||||
};
|
||||
window.onDrawFrame = () {
|
||||
try {
|
||||
_profile.record('drawFrameDuration', () {
|
||||
_profile!.record('drawFrameDuration', () {
|
||||
final SceneBuilder sceneBuilder = SceneBuilder();
|
||||
onDrawFrame(sceneBuilder);
|
||||
_profile.record('sceneBuildDuration', () {
|
||||
_profile!.record('sceneBuildDuration', () {
|
||||
final Scene scene = sceneBuilder.build();
|
||||
_profile.record('windowRenderDuration', () {
|
||||
_profile!.record('windowRenderDuration', () {
|
||||
window.render(scene);
|
||||
}, reported: false);
|
||||
}, reported: false);
|
||||
@@ -334,7 +334,7 @@ abstract class SceneBuilderRecorder extends Recorder {
|
||||
/// ```
|
||||
abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
||||
WidgetRecorder({
|
||||
@required String name,
|
||||
required String name,
|
||||
this.useCustomWarmUp = false,
|
||||
}) : super._(name, true);
|
||||
|
||||
@@ -352,18 +352,18 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
||||
}
|
||||
|
||||
@override
|
||||
Profile profile;
|
||||
Completer<void> _runCompleter;
|
||||
Profile? profile;
|
||||
Completer<void>? _runCompleter;
|
||||
|
||||
/// Whether to delimit warm-up frames in a custom way.
|
||||
final bool useCustomWarmUp;
|
||||
|
||||
Stopwatch _drawFrameStopwatch;
|
||||
late Stopwatch _drawFrameStopwatch;
|
||||
|
||||
@override
|
||||
@mustCallSuper
|
||||
void frameWillDraw() {
|
||||
startMeasureFrame(profile);
|
||||
startMeasureFrame(profile!);
|
||||
_drawFrameStopwatch = Stopwatch()..start();
|
||||
}
|
||||
|
||||
@@ -371,20 +371,20 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
||||
@mustCallSuper
|
||||
void frameDidDraw() {
|
||||
endMeasureFrame();
|
||||
profile.addDataPoint('drawFrameDuration', _drawFrameStopwatch.elapsed, reported: true);
|
||||
profile!.addDataPoint('drawFrameDuration', _drawFrameStopwatch.elapsed, reported: true);
|
||||
|
||||
if (shouldContinue()) {
|
||||
window.scheduleFrame();
|
||||
} else {
|
||||
for (final VoidCallback fn in _didStopCallbacks)
|
||||
fn();
|
||||
_runCompleter.complete();
|
||||
_runCompleter!.complete();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void _onError(dynamic error, StackTrace stackTrace) {
|
||||
_runCompleter.completeError(error, stackTrace);
|
||||
void _onError(Object error, StackTrace? stackTrace) {
|
||||
_runCompleter!.completeError(error, stackTrace);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -413,7 +413,7 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
||||
binding._beginRecording(this, widget);
|
||||
|
||||
try {
|
||||
await _runCompleter.future;
|
||||
await _runCompleter!.future;
|
||||
return localProfile;
|
||||
} finally {
|
||||
stopListeningToEngineBenchmarkValues(kProfilePrerollFrame);
|
||||
@@ -432,7 +432,7 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
|
||||
/// performance of frames that render the widget and ignoring the frames that
|
||||
/// clear the screen.
|
||||
abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
||||
WidgetBuildRecorder({@required String name}) : super._(name, true);
|
||||
WidgetBuildRecorder({required String name}) : super._(name, true);
|
||||
|
||||
/// Creates a widget to be benchmarked.
|
||||
///
|
||||
@@ -448,10 +448,10 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
||||
}
|
||||
|
||||
@override
|
||||
Profile profile;
|
||||
Completer<void> _runCompleter;
|
||||
Profile? profile;
|
||||
Completer<void>? _runCompleter;
|
||||
|
||||
Stopwatch _drawFrameStopwatch;
|
||||
late Stopwatch _drawFrameStopwatch;
|
||||
|
||||
/// Whether in this frame we should call [createWidget] and render it.
|
||||
///
|
||||
@@ -459,9 +459,9 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
||||
bool showWidget = true;
|
||||
|
||||
/// The state that hosts the widget under test.
|
||||
_WidgetBuildRecorderHostState _hostState;
|
||||
late _WidgetBuildRecorderHostState _hostState;
|
||||
|
||||
Widget _getWidgetForFrame() {
|
||||
Widget? _getWidgetForFrame() {
|
||||
if (showWidget) {
|
||||
return createWidget();
|
||||
} else {
|
||||
@@ -473,7 +473,7 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
||||
@mustCallSuper
|
||||
void frameWillDraw() {
|
||||
if (showWidget) {
|
||||
startMeasureFrame(profile);
|
||||
startMeasureFrame(profile!);
|
||||
_drawFrameStopwatch = Stopwatch()..start();
|
||||
}
|
||||
}
|
||||
@@ -484,7 +484,7 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
||||
// Only record frames that show the widget.
|
||||
if (showWidget) {
|
||||
endMeasureFrame();
|
||||
profile.addDataPoint('drawFrameDuration', _drawFrameStopwatch.elapsed, reported: true);
|
||||
profile!.addDataPoint('drawFrameDuration', _drawFrameStopwatch.elapsed, reported: true);
|
||||
}
|
||||
|
||||
if (shouldContinue()) {
|
||||
@@ -493,13 +493,13 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
||||
} else {
|
||||
for (final VoidCallback fn in _didStopCallbacks)
|
||||
fn();
|
||||
_runCompleter.complete();
|
||||
_runCompleter!.complete();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void _onError(dynamic error, StackTrace stackTrace) {
|
||||
_runCompleter.completeError(error, stackTrace);
|
||||
void _onError(Object error, StackTrace? stackTrace) {
|
||||
_runCompleter!.completeError(error, stackTrace);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -511,7 +511,7 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
|
||||
binding._beginRecording(this, _WidgetBuildRecorderHost(this));
|
||||
|
||||
try {
|
||||
await _runCompleter.future;
|
||||
await _runCompleter!.future;
|
||||
return localProfile;
|
||||
} finally {
|
||||
_runCompleter = null;
|
||||
@@ -578,11 +578,11 @@ class Timeseries {
|
||||
|
||||
/// The number of frames ignored as warm-up frames, used only
|
||||
/// when [useCustomWarmUp] is true.
|
||||
int _warmUpFrameCount;
|
||||
int? _warmUpFrameCount;
|
||||
|
||||
/// The number of frames ignored as warm-up frames.
|
||||
int get warmUpFrameCount => useCustomWarmUp
|
||||
? _warmUpFrameCount
|
||||
? _warmUpFrameCount!
|
||||
: count - _kMeasuredSampleCount;
|
||||
|
||||
/// List of all the values that have been recorded.
|
||||
@@ -664,7 +664,7 @@ class Timeseries {
|
||||
}
|
||||
|
||||
/// Adds a value to this timeseries.
|
||||
void add(double value, {@required bool isWarmUpValue}) {
|
||||
void add(double value, {required bool isWarmUpValue}) {
|
||||
if (value < 0.0) {
|
||||
throw StateError(
|
||||
'Timeseries $name: negative metric values are not supported. Got: $value',
|
||||
@@ -672,7 +672,7 @@ class Timeseries {
|
||||
}
|
||||
_allValues.add(value);
|
||||
if (useCustomWarmUp && isWarmUpValue) {
|
||||
_warmUpFrameCount += 1;
|
||||
_warmUpFrameCount = (_warmUpFrameCount ?? 0) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -683,15 +683,15 @@ class Timeseries {
|
||||
@sealed
|
||||
class TimeseriesStats {
|
||||
const TimeseriesStats({
|
||||
@required this.name,
|
||||
@required this.average,
|
||||
@required this.outlierCutOff,
|
||||
@required this.outlierAverage,
|
||||
@required this.standardDeviation,
|
||||
@required this.noise,
|
||||
@required this.cleanSampleCount,
|
||||
@required this.outlierSampleCount,
|
||||
@required this.samples,
|
||||
required this.name,
|
||||
required this.average,
|
||||
required this.outlierCutOff,
|
||||
required this.outlierAverage,
|
||||
required this.standardDeviation,
|
||||
required this.noise,
|
||||
required this.cleanSampleCount,
|
||||
required this.outlierSampleCount,
|
||||
required this.samples,
|
||||
});
|
||||
|
||||
/// The label used to refer to the corresponding timeseries.
|
||||
@@ -764,9 +764,9 @@ class TimeseriesStats {
|
||||
@sealed
|
||||
class AnnotatedSample {
|
||||
const AnnotatedSample({
|
||||
@required this.magnitude,
|
||||
@required this.isOutlier,
|
||||
@required this.isWarmUpValue,
|
||||
required this.magnitude,
|
||||
required this.isOutlier,
|
||||
required this.isWarmUpValue,
|
||||
});
|
||||
|
||||
/// The non-negative raw result of the measurement.
|
||||
@@ -787,7 +787,7 @@ class AnnotatedSample {
|
||||
|
||||
/// Base class for a profile collected from running a benchmark.
|
||||
class Profile {
|
||||
Profile({@required this.name, this.useCustomWarmUp = false})
|
||||
Profile({required this.name, this.useCustomWarmUp = false})
|
||||
: assert(name != null),
|
||||
_isWarmingUp = useCustomWarmUp;
|
||||
|
||||
@@ -824,7 +824,7 @@ class Profile {
|
||||
final Map<String, dynamic> extraData = <String, dynamic>{};
|
||||
|
||||
/// Invokes [callback] and records the duration of its execution under [key].
|
||||
Duration record(String key, VoidCallback callback, { @required bool reported }) {
|
||||
Duration record(String key, VoidCallback callback, { required bool reported }) {
|
||||
final Duration duration = timeAction(callback);
|
||||
addDataPoint(key, duration, reported: reported);
|
||||
return duration;
|
||||
@@ -836,7 +836,7 @@ class Profile {
|
||||
///
|
||||
/// Set [reported] to `false` to store the data, but not show it on the
|
||||
/// dashboard UI.
|
||||
void addDataPoint(String key, Duration duration, { @required bool reported }) {
|
||||
void addDataPoint(String key, Duration duration, { required bool reported }) {
|
||||
scoreData.putIfAbsent(
|
||||
key,
|
||||
() => Timeseries(key, reported, useCustomWarmUp: useCustomWarmUp),
|
||||
@@ -860,7 +860,7 @@ class Profile {
|
||||
|
||||
// We have recorded something, but do we have enough samples? If every
|
||||
// timeseries has collected enough samples, stop the benchmark.
|
||||
return !scoreData.keys.every((String key) => scoreData[key].count >= kTotalSampleCount);
|
||||
return !scoreData.keys.every((String key) => scoreData[key]!.count >= kTotalSampleCount);
|
||||
}
|
||||
|
||||
/// Returns a JSON representation of the profile that will be sent to the
|
||||
@@ -873,7 +873,7 @@ class Profile {
|
||||
};
|
||||
|
||||
for (final String key in scoreData.keys) {
|
||||
final Timeseries timeseries = scoreData[key];
|
||||
final Timeseries timeseries = scoreData[key]!;
|
||||
|
||||
if (timeseries.isReported) {
|
||||
scoreKeys.add('$key.average');
|
||||
@@ -900,7 +900,7 @@ class Profile {
|
||||
final StringBuffer buffer = StringBuffer();
|
||||
buffer.writeln('name: $name');
|
||||
for (final String key in scoreData.keys) {
|
||||
final Timeseries timeseries = scoreData[key];
|
||||
final Timeseries timeseries = scoreData[key]!;
|
||||
final TimeseriesStats stats = timeseries.computeStats();
|
||||
buffer.writeln(stats.toString());
|
||||
}
|
||||
@@ -967,7 +967,7 @@ abstract class FrameRecorder {
|
||||
/// Reports an error.
|
||||
///
|
||||
/// The implementation is expected to halt benchmark execution as soon as possible.
|
||||
void _onError(dynamic error, StackTrace stackTrace);
|
||||
void _onError(Object error, StackTrace? stackTrace);
|
||||
}
|
||||
|
||||
/// A variant of [WidgetsBinding] that collaborates with a [Recorder] to decide
|
||||
@@ -992,10 +992,10 @@ class _RecordingWidgetsBinding extends BindingBase
|
||||
if (WidgetsBinding.instance == null) {
|
||||
_RecordingWidgetsBinding();
|
||||
}
|
||||
return WidgetsBinding.instance as _RecordingWidgetsBinding;
|
||||
return WidgetsBinding.instance! as _RecordingWidgetsBinding;
|
||||
}
|
||||
|
||||
FrameRecorder _recorder;
|
||||
FrameRecorder? _recorder;
|
||||
bool _hasErrored = false;
|
||||
|
||||
/// To short-circuit all frame lifecycle methods when the benchmark has
|
||||
@@ -1008,7 +1008,7 @@ class _RecordingWidgetsBinding extends BindingBase
|
||||
'Cannot call _RecordingWidgetsBinding._beginRecording more than once',
|
||||
);
|
||||
}
|
||||
final FlutterExceptionHandler originalOnError = FlutterError.onError;
|
||||
final FlutterExceptionHandler? originalOnError = FlutterError.onError;
|
||||
|
||||
recorder.registerDidStop(() {
|
||||
_benchmarkStopped = true;
|
||||
@@ -1017,22 +1017,22 @@ class _RecordingWidgetsBinding extends BindingBase
|
||||
// Fail hard and fast on errors. Benchmarks should not have any errors.
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
_haltBenchmarkWithError(details.exception, details.stack);
|
||||
originalOnError(details);
|
||||
originalOnError?.call(details);
|
||||
};
|
||||
_recorder = recorder;
|
||||
runApp(widget);
|
||||
}
|
||||
|
||||
void _haltBenchmarkWithError(dynamic error, StackTrace stackTrace) {
|
||||
void _haltBenchmarkWithError(Object error, StackTrace? stackTrace) {
|
||||
if (_hasErrored) {
|
||||
return;
|
||||
}
|
||||
_recorder._onError(error, stackTrace);
|
||||
_recorder?._onError(error, stackTrace);
|
||||
_hasErrored = true;
|
||||
}
|
||||
|
||||
@override
|
||||
void handleBeginFrame(Duration rawTimeStamp) {
|
||||
void handleBeginFrame(Duration? rawTimeStamp) {
|
||||
// Don't keep on truckin' if there's an error or the benchmark has stopped.
|
||||
if (_hasErrored || _benchmarkStopped) {
|
||||
return;
|
||||
@@ -1061,9 +1061,9 @@ class _RecordingWidgetsBinding extends BindingBase
|
||||
return;
|
||||
}
|
||||
try {
|
||||
_recorder.frameWillDraw();
|
||||
_recorder?.frameWillDraw();
|
||||
super.handleDrawFrame();
|
||||
_recorder.frameDidDraw();
|
||||
_recorder?.frameDidDraw();
|
||||
} catch (error, stackTrace) {
|
||||
_haltBenchmarkWithError(error, stackTrace);
|
||||
rethrow;
|
||||
@@ -1189,7 +1189,7 @@ void stopListeningToEngineBenchmarkValues(String name) {
|
||||
//
|
||||
// If there are no listeners registered for [name], ignores the value.
|
||||
void _dispatchEngineBenchmarkValue(String name, double value) {
|
||||
final EngineBenchmarkValueListener listener = _engineBenchmarkListeners[name];
|
||||
final EngineBenchmarkValueListener? listener = _engineBenchmarkListeners[name];
|
||||
if (listener != null) {
|
||||
listener(value);
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
// Used to randomize data.
|
||||
//
|
||||
// Using constant seed for reproducibility.
|
||||
@@ -34,11 +32,11 @@ final List<String> lipsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing
|
||||
/// Generates strings and builds pre-laid out paragraphs to be used by
|
||||
/// benchmarks.
|
||||
List<Paragraph> generateLaidOutParagraphs({
|
||||
@required int paragraphCount,
|
||||
@required int minWordCountPerParagraph,
|
||||
@required int maxWordCountPerParagraph,
|
||||
@required double widthConstraint,
|
||||
@required Color color,
|
||||
required int paragraphCount,
|
||||
required int minWordCountPerParagraph,
|
||||
required int maxWordCountPerParagraph,
|
||||
required double widthConstraint,
|
||||
required Color color,
|
||||
}) {
|
||||
final List<Paragraph> strings = <Paragraph>[];
|
||||
int wordPointer = 0; // points to the next word in lipsum to extract
|
||||
|
||||
Reference in New Issue
Block a user