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
be5b5c89
Unverified
Commit
be5b5c89
authored
May 28, 2020
by
Yegor
Committed by
GitHub
May 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a backward variant of BenchCardInfiniteScroll (#58140)
parent
9989c54c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
21 deletions
+37
-21
bench_card_infinite_scroll.dart
...crobenchmarks/lib/src/web/bench_card_infinite_scroll.dart
+35
-20
web_benchmarks.dart
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
+2
-1
No files found.
dev/benchmarks/macrobenchmarks/lib/src/web/bench_card_infinite_scroll.dart
View file @
be5b5c89
...
...
@@ -11,48 +11,62 @@ import 'test_data.dart';
/// Creates an infinite list of Material cards and scrolls it.
class
BenchCardInfiniteScroll
extends
WidgetRecorder
{
BenchCardInfiniteScroll
()
:
super
(
name:
benchmarkName
);
BenchCardInfiniteScroll
.
forward
()
:
initialOffset
=
0.0
,
finalOffset
=
30000.0
,
super
(
name:
benchmarkName
);
BenchCardInfiniteScroll
.
backward
()
:
initialOffset
=
30000.0
,
finalOffset
=
0.0
,
super
(
name:
benchmarkNameBackward
);
static
const
String
benchmarkName
=
'bench_card_infinite_scroll'
;
static
const
String
benchmarkNameBackward
=
'bench_card_infinite_scroll_backward'
;
final
double
initialOffset
;
final
double
finalOffset
;
@override
Widget
createWidget
()
=>
const
MaterialApp
(
Widget
createWidget
()
=>
MaterialApp
(
title:
'Infinite Card Scroll Benchmark'
,
home:
_InfiniteScrollCards
(
),
home:
_InfiniteScrollCards
(
initialOffset
,
finalOffset
),
);
}
class
_InfiniteScrollCards
extends
StatefulWidget
{
const
_InfiniteScrollCards
({
Key
key
})
:
super
(
key:
key
);
const
_InfiniteScrollCards
(
this
.
initialOffset
,
this
.
finalOffset
,
{
Key
key
})
:
super
(
key:
key
);
final
double
initialOffset
;
final
double
finalOffset
;
@override
State
<
_InfiniteScrollCards
>
createState
()
=>
_InfiniteScrollCardsState
();
}
class
_InfiniteScrollCardsState
extends
State
<
_InfiniteScrollCards
>
{
ScrollController
scrollController
;
static
const
Duration
stepDuration
=
Duration
(
seconds:
20
)
;
ScrollController
scrollController
;
double
offset
;
static
const
double
distance
=
1000
;
static
const
Duration
stepDuration
=
Duration
(
seconds:
1
);
@override
void
initState
()
{
super
.
initState
();
scrollController
=
ScrollController
();
offset
=
0
;
offset
=
widget
.
initialOffset
;
scrollController
=
ScrollController
(
initialScrollOffset:
offset
,
);
// Without the timer the animation doesn't begin.
Timer
.
run
(()
async
{
while
(
true
)
{
await
scrollController
.
animateTo
(
offset
+
distance
,
widget
.
finalOffset
,
curve:
Curves
.
linear
,
duration:
stepDuration
,
);
offset
+=
distance
;
}
});
}
...
...
@@ -60,13 +74,14 @@ class _InfiniteScrollCardsState extends State<_InfiniteScrollCards> {
Widget
build
(
BuildContext
context
)
{
return
ListView
.
builder
(
controller:
scrollController
,
itemExtent:
100.0
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
SizedBox
(
height:
100.0
,
child:
Card
(
elevation:
16.0
,
child:
Text
(
lipsum
[
index
%
lipsum
.
length
]
,
'
${lipsum[index % lipsum.length]}
$index
'
,
textAlign:
TextAlign
.
center
,
),
),
...
...
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
View file @
be5b5c89
...
...
@@ -30,7 +30,8 @@ const bool isCanvasKit = bool.fromEnvironment('FLUTTER_WEB_USE_SKIA', defaultVal
/// When adding a new benchmark, add it to this map. Make sure that the name
/// of your benchmark is unique.
final
Map
<
String
,
RecorderFactory
>
benchmarks
=
<
String
,
RecorderFactory
>{
BenchCardInfiniteScroll
.
benchmarkName
:
()
=>
BenchCardInfiniteScroll
(),
BenchCardInfiniteScroll
.
benchmarkName
:
()
=>
BenchCardInfiniteScroll
.
forward
(),
BenchCardInfiniteScroll
.
benchmarkNameBackward
:
()
=>
BenchCardInfiniteScroll
.
backward
(),
BenchClippedOutPictures
.
benchmarkName
:
()
=>
BenchClippedOutPictures
(),
BenchDrawRect
.
benchmarkName
:
()
=>
BenchDrawRect
(),
BenchPathRecording
.
benchmarkName
:
()
=>
BenchPathRecording
(),
...
...
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