forked from firka/flutter
benchmark memory usage for grid view of memory intensive widgets (#61025)
This commit is contained in:
@@ -15,5 +15,6 @@ const String kColorFilterAndFadeRouteName = '/color_filter_and_fade';
|
||||
const String kFadingChildAnimationRouteName = '/fading_child_animation';
|
||||
const String kImageFilteredTransformAnimationRouteName = '/imagefiltered_transform_animation';
|
||||
const String kMultiWidgetConstructionRouteName = '/multi_widget_construction';
|
||||
const String kHeavyGridViewRouteName = '/heavy_gridview';
|
||||
|
||||
const String kScrollableName = '/macrobenchmark_listview';
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:macrobenchmarks/src/color_filter_and_fade.dart';
|
||||
import 'package:macrobenchmarks/src/heavy_grid_view.dart';
|
||||
import 'package:macrobenchmarks/src/large_images.dart';
|
||||
import 'package:macrobenchmarks/src/picture_cache.dart';
|
||||
|
||||
@@ -45,6 +46,7 @@ class MacrobenchmarksApp extends StatelessWidget {
|
||||
kFadingChildAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.opacity),
|
||||
kImageFilteredTransformAnimationRouteName: (BuildContext context) => const FilteredChildAnimationPage(FilterType.rotateFilter),
|
||||
kMultiWidgetConstructionRouteName: (BuildContext context) => const MultiWidgetConstructTable(10, 20),
|
||||
kHeavyGridViewRouteName: (BuildContext context) => HeavyGridViewPage(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -151,6 +153,13 @@ class HomePage extends StatelessWidget {
|
||||
Navigator.pushNamed(context, kMultiWidgetConstructionRouteName);
|
||||
},
|
||||
),
|
||||
RaisedButton(
|
||||
key: const Key(kHeavyGridViewRouteName),
|
||||
child: const Text('Heavy Grid View'),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, kHeavyGridViewRouteName);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
32
dev/benchmarks/macrobenchmarks/lib/src/heavy_grid_view.dart
Normal file
32
dev/benchmarks/macrobenchmarks/lib/src/heavy_grid_view.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
// 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/material.dart';
|
||||
|
||||
class HeavyGridViewPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GridView.builder(
|
||||
itemCount: 1000,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
|
||||
itemBuilder: (BuildContext context, int index) => HeavyWidget(index),
|
||||
).build(context);
|
||||
}
|
||||
}
|
||||
|
||||
class HeavyWidget extends StatelessWidget {
|
||||
HeavyWidget(this.index) : super(key: ValueKey<int>(index));
|
||||
|
||||
final int index;
|
||||
final List<int> _weight = List<int>(1000000);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 200,
|
||||
height: 200,
|
||||
child: Text('$index: ${_weight.length}'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// 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 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:macrobenchmarks/common.dart';
|
||||
import 'package:macrobenchmarks/main.dart';
|
||||
|
||||
Future<void> endOfAnimation() async {
|
||||
do {
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
} while (SchedulerBinding.instance.hasScheduledFrame);
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
runApp(const MacrobenchmarksApp(initialRoute: kHeavyGridViewRouteName));
|
||||
await endOfAnimation();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 50));
|
||||
debugPrint('==== MEMORY BENCHMARK ==== READY ====');
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// 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 'package:flutter_devicelab/framework/adb.dart';
|
||||
import 'package:flutter_devicelab/framework/framework.dart';
|
||||
import 'package:flutter_devicelab/framework/utils.dart';
|
||||
import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
|
||||
const String kPackageName = 'com.example.macrobenchmarks';
|
||||
const String kActivityName = 'com.example.macrobenchmarks.MainActivity';
|
||||
|
||||
class FastScrollHeavyGridViewMemoryTest extends MemoryTest {
|
||||
FastScrollHeavyGridViewMemoryTest()
|
||||
: super(
|
||||
'${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',
|
||||
'test_memory/heavy_gridview.dart', kPackageName,
|
||||
);
|
||||
|
||||
@override
|
||||
AndroidDevice get device => super.device as AndroidDevice;
|
||||
|
||||
@override
|
||||
int get iterationCount => 5;
|
||||
|
||||
@override
|
||||
Future<void> useMemory() async {
|
||||
await launchApp();
|
||||
await recordStart();
|
||||
await device.shellExec('input', <String>['swipe', '50 1500 50 50 50']);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 1500));
|
||||
await device.shellExec('input', <String>['swipe', '50 1500 50 50 50']);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 1500));
|
||||
await device.shellExec('input', <String>['swipe', '50 1500 50 50 50']);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 1500));
|
||||
await recordEnd();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
deviceOperatingSystem = DeviceOperatingSystem.android;
|
||||
await task(FastScrollHeavyGridViewMemoryTest().run);
|
||||
}
|
||||
@@ -803,6 +803,14 @@ tasks:
|
||||
stage: devicelab
|
||||
required_agent_capabilities: ["mac/android"]
|
||||
|
||||
fast_scroll_heavy_gridview__memory:
|
||||
description: >
|
||||
Measures memory usage for scrolling through a grid view of heavy memory
|
||||
usage widgets.
|
||||
stage: devicelab
|
||||
required_agent_capabilities: ["linux/android"]
|
||||
flaky: true
|
||||
|
||||
animated_placeholder_perf:
|
||||
description: >
|
||||
Measures frame build and rasterizer times, as well as frame build counts
|
||||
|
||||
Reference in New Issue
Block a user