Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a2005eaf
Commit
a2005eaf
authored
Dec 06, 2019
by
liyuqian
Committed by
Flutter GitHub Bot
Dec 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Memory test on scrolling large images quickly (#46184)
parent
42cb9190
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
148 additions
and
3 deletions
+148
-3
999x1000.png
dev/benchmarks/macrobenchmarks/assets/999x1000.png
+0
-0
common.dart
dev/benchmarks/macrobenchmarks/lib/common.dart
+1
-0
main.dart
dev/benchmarks/macrobenchmarks/lib/main.dart
+16
-3
large_images.dart
dev/benchmarks/macrobenchmarks/lib/src/large_images.dart
+48
-0
pubspec.yaml
dev/benchmarks/macrobenchmarks/pubspec.yaml
+1
-0
large_images.dart
dev/benchmarks/macrobenchmarks/test_memory/large_images.dart
+35
-0
fast_scroll_large_images__memory.dart
...devicelab/bin/tasks/fast_scroll_large_images__memory.dart
+41
-0
manifest.yaml
dev/devicelab/manifest.yaml
+6
-0
No files found.
dev/benchmarks/macrobenchmarks/assets/999x1000.png
0 → 100644
View file @
a2005eaf
This diff was suppressed by a .gitattributes entry.
dev/benchmarks/macrobenchmarks/lib/common.dart
View file @
a2005eaf
...
@@ -7,3 +7,4 @@ const String kCubicBezierRouteName = '/cubic_bezier';
...
@@ -7,3 +7,4 @@ const String kCubicBezierRouteName = '/cubic_bezier';
const
String
kBackdropFilterRouteName
=
'/backdrop_filter'
;
const
String
kBackdropFilterRouteName
=
'/backdrop_filter'
;
const
String
kSimpleAnimationRouteName
=
'/simple_animation'
;
const
String
kSimpleAnimationRouteName
=
'/simple_animation'
;
const
String
kPictureCacheRouteName
=
'/picture_cache'
;
const
String
kPictureCacheRouteName
=
'/picture_cache'
;
const
String
kLargeImagesRouteName
=
'/large_images'
;
dev/benchmarks/macrobenchmarks/lib/main.dart
View file @
a2005eaf
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:macrobenchmarks/src/large_images.dart'
;
import
'package:macrobenchmarks/src/picture_cache.dart'
;
import
'package:macrobenchmarks/src/picture_cache.dart'
;
import
'common.dart'
;
import
'common.dart'
;
...
@@ -13,24 +14,29 @@ import 'src/simple_animation.dart';
...
@@ -13,24 +14,29 @@ import 'src/simple_animation.dart';
const
String
kMacrobenchmarks
=
'Macrobenchmarks'
;
const
String
kMacrobenchmarks
=
'Macrobenchmarks'
;
void
main
(
)
=>
runApp
(
MacrobenchmarksApp
());
void
main
(
)
=>
runApp
(
const
MacrobenchmarksApp
());
class
MacrobenchmarksApp
extends
StatelessWidget
{
class
MacrobenchmarksApp
extends
StatelessWidget
{
const
MacrobenchmarksApp
({
this
.
initialRoute
=
'/'
});
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
return
MaterialApp
(
title:
kMacrobenchmarks
,
title:
kMacrobenchmarks
,
initialRoute:
'/'
,
initialRoute:
initialRoute
,
routes:
<
String
,
WidgetBuilder
>{
routes:
<
String
,
WidgetBuilder
>{
'/'
:
(
BuildContext
context
)
=>
HomePage
(),
'/'
:
(
BuildContext
context
)
=>
HomePage
(),
kCullOpacityRouteName:
(
BuildContext
context
)
=>
CullOpacityPage
(),
kCullOpacityRouteName:
(
BuildContext
context
)
=>
CullOpacityPage
(),
kCubicBezierRouteName:
(
BuildContext
context
)
=>
CubicBezierPage
(),
kCubicBezierRouteName:
(
BuildContext
context
)
=>
CubicBezierPage
(),
kBackdropFilterRouteName:
(
BuildContext
context
)
=>
BackdropFilterPage
(),
kBackdropFilterRouteName:
(
BuildContext
context
)
=>
BackdropFilterPage
(),
kSimpleAnimationRouteName:
(
BuildContext
conttext
)
=>
SimpleAnimationPage
(),
kSimpleAnimationRouteName:
(
BuildContext
conttext
)
=>
SimpleAnimationPage
(),
kPictureCacheRouteName:
(
BuildContext
conttext
)
=>
PictureCachePage
(),
kPictureCacheRouteName:
(
BuildContext
context
)
=>
PictureCachePage
(),
kLargeImagesRouteName:
(
BuildContext
context
)
=>
LargeImagesPage
(),
},
},
);
);
}
}
final
String
initialRoute
;
}
}
class
HomePage
extends
StatelessWidget
{
class
HomePage
extends
StatelessWidget
{
...
@@ -75,6 +81,13 @@ class HomePage extends StatelessWidget {
...
@@ -75,6 +81,13 @@ class HomePage extends StatelessWidget {
Navigator
.
pushNamed
(
context
,
kPictureCacheRouteName
);
Navigator
.
pushNamed
(
context
,
kPictureCacheRouteName
);
},
},
),
),
RaisedButton
(
key:
const
Key
(
kLargeImagesRouteName
),
child:
const
Text
(
'Large Images'
),
onPressed:
()
{
Navigator
.
pushNamed
(
context
,
kLargeImagesRouteName
);
},
),
],
],
),
),
);
);
...
...
dev/benchmarks/macrobenchmarks/lib/src/large_images.dart
0 → 100644
View file @
a2005eaf
// 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:typed_data'
;
import
'package:flutter/material.dart'
;
class
LargeImagesPage
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
final
ImageCache
imageCache
=
PaintingBinding
.
instance
.
imageCache
;
imageCache
.
maximumSize
=
30
;
imageCache
.
maximumSizeBytes
=
50
<<
20
;
return
GridView
.
builder
(
itemCount:
1000
,
gridDelegate:
const
SliverGridDelegateWithFixedCrossAxisCount
(
crossAxisCount:
3
),
itemBuilder:
(
BuildContext
context
,
int
index
)
=>
DummyImage
(
index
),
).
build
(
context
);
}
}
class
DummyImage
extends
StatelessWidget
{
DummyImage
(
this
.
index
)
:
super
(
key:
ValueKey
<
int
>(
index
));
@override
Widget
build
(
BuildContext
context
)
{
final
Future
<
ByteData
>
pngData
=
_getPngData
(
context
);
return
FutureBuilder
<
ByteData
>(
future:
pngData
,
builder:
(
BuildContext
context
,
AsyncSnapshot
<
ByteData
>
snapshot
)
{
// Use Image.memory instead of Image.asset to make sure that we're
// creating many copies of the image to trigger the memory issue.
return
snapshot
.
data
==
null
?
Container
()
:
Image
.
memory
(
snapshot
.
data
.
buffer
.
asUint8List
());
},
);
}
final
int
index
;
Future
<
ByteData
>
_getPngData
(
BuildContext
context
)
async
{
return
DefaultAssetBundle
.
of
(
context
).
load
(
'assets/999x1000.png'
);
}
}
dev/benchmarks/macrobenchmarks/pubspec.yaml
View file @
a2005eaf
...
@@ -90,5 +90,6 @@ flutter:
...
@@ -90,5 +90,6 @@ flutter:
assets
:
assets
:
-
packages/flutter_gallery_assets/food/butternut_squash_soup.png
-
packages/flutter_gallery_assets/food/butternut_squash_soup.png
-
packages/flutter_gallery_assets/food/cherry_pie.png
-
packages/flutter_gallery_assets/food/cherry_pie.png
-
assets/999x1000.png
# PUBSPEC CHECKSUM: 4cef
# PUBSPEC CHECKSUM: 4cef
dev/benchmarks/macrobenchmarks/test_memory/large_images.dart
0 → 100644
View file @
a2005eaf
// 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
);
}
int
iteration
=
0
;
class
LifecycleObserver
extends
WidgetsBindingObserver
{
@override
void
didChangeAppLifecycleState
(
AppLifecycleState
state
)
{
debugPrint
(
'==== MEMORY BENCHMARK ====
$state
===='
);
debugPrint
(
'This was lifecycle event number
$iteration
in this instance'
);
}
}
Future
<
void
>
main
()
async
{
runApp
(
const
MacrobenchmarksApp
(
initialRoute:
kLargeImagesRouteName
));
await
endOfAnimation
();
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
50
));
debugPrint
(
'==== MEMORY BENCHMARK ==== READY ===='
);
WidgetsBinding
.
instance
.
addObserver
(
LifecycleObserver
());
}
dev/devicelab/bin/tasks/fast_scroll_large_images__memory.dart
0 → 100644
View file @
a2005eaf
// 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
FastScrollLargeImagesMemoryTest
extends
MemoryTest
{
FastScrollLargeImagesMemoryTest
()
:
super
(
'
${flutterDirectory.path}
/dev/benchmarks/macrobenchmarks'
,
'test_memory/large_images.dart'
,
kPackageName
,
);
@override
AndroidDevice
get
device
=>
super
.
device
;
@override
int
get
iterationCount
=>
5
;
@override
Future
<
void
>
useMemory
()
async
{
await
launchApp
();
await
recordStart
();
await
device
.
shellExec
(
'input'
,
<
String
>[
'swipe'
,
'0 1500 0 0 50'
]);
await
Future
<
void
>.
delayed
(
const
Duration
(
milliseconds:
10000
));
await
recordEnd
();
}
}
Future
<
void
>
main
()
async
{
deviceOperatingSystem
=
DeviceOperatingSystem
.
android
;
await
task
(
FastScrollLargeImagesMemoryTest
().
run
);
}
dev/devicelab/manifest.yaml
View file @
a2005eaf
...
@@ -670,6 +670,12 @@ tasks:
...
@@ -670,6 +670,12 @@ tasks:
stage
:
devicelab
stage
:
devicelab
required_agent_capabilities
:
[
"
linux/android"
]
required_agent_capabilities
:
[
"
linux/android"
]
fast_scroll_large_images__memory
:
description
:
>
Measures memory usage for scrolling through a list of large images.
stage
:
devicelab
required_agent_capabilities
:
[
"
mac/android"
]
analyzer_benchmark
:
analyzer_benchmark
:
description
:
>
description
:
>
Measures the speed of Dart analyzer.
Measures the speed of Dart analyzer.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment