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
33fb35e9
Unverified
Commit
33fb35e9
authored
Oct 02, 2020
by
Dan Field
Committed by
GitHub
Oct 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add benchmark/test for drawing images across frames (#67176)
parent
f6cbf488
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
0 deletions
+90
-0
bench_build_image.dart
...hmarks/macrobenchmarks/lib/src/web/bench_build_image.dart
+88
-0
web_benchmarks.dart
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
+2
-0
No files found.
dev/benchmarks/macrobenchmarks/lib/src/web/bench_build_image.dart
0 → 100644
View file @
33fb35e9
// 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:math'
as
math
;
import
'dart:typed_data'
;
import
'package:flutter/widgets.dart'
;
import
'recorder.dart'
;
const
List
<
int
>
kTransparentImage
=
<
int
>[
0x89
,
0x50
,
0x4E
,
0x47
,
0x0D
,
0x0A
,
0x1A
,
0x0A
,
0x00
,
0x00
,
0x00
,
0x0D
,
0x49
,
0x48
,
0x44
,
0x52
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0x01
,
0x08
,
0x06
,
0x00
,
0x00
,
0x00
,
0x1F
,
0x15
,
0xC4
,
0x89
,
0x00
,
0x00
,
0x00
,
0x0A
,
0x49
,
0x44
,
0x41
,
0x54
,
0x78
,
0x9C
,
0x63
,
0x00
,
0x01
,
0x00
,
0x00
,
0x05
,
0x00
,
0x01
,
0x0D
,
0x0A
,
0x2D
,
0xB4
,
0x00
,
0x00
,
0x00
,
0x00
,
0x49
,
0x45
,
0x4E
,
0x44
,
0xAE
,
];
/// 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
List
<
int
>
kAnimatedGif
=
<
int
>
[
0x47
,
0x49
,
0x46
,
0x38
,
0x39
,
0x61
,
0x01
,
0x00
,
0x01
,
0x00
,
0xa1
,
0x03
,
0x00
,
0x00
,
0x00
,
0xff
,
0xff
,
0x00
,
0x00
,
0x00
,
0xff
,
0x00
,
0xff
,
0xff
,
0xff
,
0x21
,
0xff
,
0x0b
,
0x4e
,
0x45
,
0x54
,
0x53
,
0x43
,
0x41
,
0x50
,
0x45
,
0x32
,
0x2e
,
0x30
,
0x03
,
0x01
,
0x00
,
0x00
,
0x00
,
0x21
,
0xf9
,
0x04
,
0x00
,
0x0a
,
0x00
,
0xff
,
0x00
,
0x2c
,
0x00
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x01
,
0x00
,
0x00
,
0x02
,
0x02
,
0x4c
,
0x01
,
0x00
,
0x21
,
0xf9
,
0x04
,
0x00
,
0x0a
,
0x00
,
0xff
,
0x00
,
0x2c
,
0x00
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x01
,
0x00
,
0x00
,
0x02
,
0x02
,
0x54
,
0x01
,
0x00
,
0x21
,
0xf9
,
0x04
,
0x00
,
0x0a
,
0x00
,
0xff
,
0x00
,
0x2c
,
0x00
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x01
,
0x00
,
0x00
,
0x02
,
0x02
,
0x44
,
0x01
,
0x00
,
0x3b
,
];
/// Measures expense of constructing Image widgets.
class
BenchBuildImage
extends
WidgetRecorder
{
BenchBuildImage
()
:
super
(
name:
benchmarkName
);
static
const
String
benchmarkName
=
'draw_image'
;
@override
Widget
createWidget
()
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
_RotatingWidget
(
child:
Row
(
children:
<
Widget
>[
Image
.
memory
(
Uint8List
.
fromList
(
kTransparentImage
)),
Image
.
memory
(
Uint8List
.
fromList
(
kAnimatedGif
)),
]),
),
);
}
}
class
_RotatingWidget
extends
StatefulWidget
{
const
_RotatingWidget
({
this
.
child
,
Key
key
})
:
super
(
key:
key
);
final
Widget
child
;
@override
_RotatingWidgetState
createState
()
=>
_RotatingWidgetState
();
}
class
_RotatingWidgetState
extends
State
<
_RotatingWidget
>
with
SingleTickerProviderStateMixin
{
AnimationController
controller
;
@override
void
initState
()
{
super
.
initState
();
controller
=
AnimationController
(
duration:
const
Duration
(
milliseconds:
200
),
vsync:
this
,
)..
repeat
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
AnimatedBuilder
(
animation:
controller
,
builder:
(
BuildContext
context
,
Widget
child
)
{
return
Transform
(
transform:
Matrix4
.
identity
()..
rotateZ
(
2
*
math
.
pi
*
controller
.
value
),
child:
widget
.
child
,
);
},
);
}
}
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
View file @
33fb35e9
...
@@ -12,6 +12,7 @@ import 'package:macrobenchmarks/src/web/bench_text_out_of_picture_bounds.dart';
...
@@ -12,6 +12,7 @@ import 'package:macrobenchmarks/src/web/bench_text_out_of_picture_bounds.dart';
import
'package:gallery/benchmarks/gallery_automator.dart'
show
DemoType
,
typeOfDemo
;
import
'package:gallery/benchmarks/gallery_automator.dart'
show
DemoType
,
typeOfDemo
;
import
'src/web/bench_build_image.dart'
;
import
'src/web/bench_build_material_checkbox.dart'
;
import
'src/web/bench_build_material_checkbox.dart'
;
import
'src/web/bench_card_infinite_scroll.dart'
;
import
'src/web/bench_card_infinite_scroll.dart'
;
import
'src/web/bench_child_layers.dart'
;
import
'src/web/bench_child_layers.dart'
;
...
@@ -39,6 +40,7 @@ const String _galleryBenchmarkPrefix = 'gallery_v2';
...
@@ -39,6 +40,7 @@ const String _galleryBenchmarkPrefix = 'gallery_v2';
/// When adding a new benchmark, add it to this map. Make sure that the name
/// When adding a new benchmark, add it to this map. Make sure that the name
/// of your benchmark is unique.
/// of your benchmark is unique.
final
Map
<
String
,
RecorderFactory
>
benchmarks
=
<
String
,
RecorderFactory
>{
final
Map
<
String
,
RecorderFactory
>
benchmarks
=
<
String
,
RecorderFactory
>{
BenchBuildImage
.
benchmarkName
:
()
=>
BenchBuildImage
(),
BenchCardInfiniteScroll
.
benchmarkName
:
()
=>
BenchCardInfiniteScroll
.
forward
(),
BenchCardInfiniteScroll
.
benchmarkName
:
()
=>
BenchCardInfiniteScroll
.
forward
(),
BenchCardInfiniteScroll
.
benchmarkNameBackward
:
()
=>
BenchCardInfiniteScroll
.
backward
(),
BenchCardInfiniteScroll
.
benchmarkNameBackward
:
()
=>
BenchCardInfiniteScroll
.
backward
(),
BenchClippedOutPictures
.
benchmarkName
:
()
=>
BenchClippedOutPictures
(),
BenchClippedOutPictures
.
benchmarkName
:
()
=>
BenchClippedOutPictures
(),
...
...
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