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
54cdc26a
Unverified
Commit
54cdc26a
authored
Apr 16, 2020
by
Yegor
Committed by
GitHub
Apr 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add benchmark for picture recording (#54908)
parent
53bda97c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
bench_picture_recording.dart
.../macrobenchmarks/lib/src/web/bench_picture_recording.dart
+75
-0
web_benchmarks.dart
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
+2
-0
No files found.
dev/benchmarks/macrobenchmarks/lib/src/web/bench_picture_recording.dart
0 → 100644
View file @
54cdc26a
// 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:ui'
;
import
'package:macrobenchmarks/src/web/recorder.dart'
;
/// Measure the performance of paint bounds estimation by recording a picture
/// without actually rendering it.
///
/// Bounds estimation is done in two phases:
///
/// * As we call drawing methods on `Canvas` we grow bounds with every paint op.
/// * When we're done recording a picture we call `PictureRecorder.endRecording`
/// at which point we compute the overall picture bounds and cache the result.
///
/// This benchmarks puts emphasis on paint operations that trigger expensive
/// math such as `transformLTRB`. To do that we push non-identity transforms
/// and rotations before calling drawing methods.
class
BenchPictureRecording
extends
RawRecorder
{
BenchPictureRecording
()
:
super
(
name:
benchmarkName
);
static
const
String
benchmarkName
=
'bench_picture_recording'
;
/// Cached paint used for drawing.
///
/// We want to avoid polluting the results with paint initialization logic.
Paint
paint
;
/// A prelaid out and cached paragraph.
///
/// This is cached to remove text layout time from the benchmark time.
Paragraph
paragraph
;
@override
Future
<
void
>
setUpAll
()
async
{
paint
=
Paint
();
paragraph
=
(
ParagraphBuilder
(
ParagraphStyle
())
..
addText
(
'abcd edfh ijkl mnop qrst uvwx yz'
))
.
build
()
..
layout
(
const
ParagraphConstraints
(
width:
50
));
}
@override
void
body
(
Profile
profile
)
{
final
PictureRecorder
recorder
=
PictureRecorder
();
final
Canvas
canvas
=
Canvas
(
recorder
);
profile
.
record
(
'recordPaintCommands'
,
()
{
for
(
int
i
=
1
;
i
<=
100
;
i
++)
{
canvas
.
translate
((
10
+
i
).
toDouble
(),
(
10
+
i
).
toDouble
());
canvas
.
save
();
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
canvas
.
drawRect
(
const
Rect
.
fromLTWH
(
10
,
10
,
10
,
10
),
paint
);
canvas
.
drawCircle
(
const
Offset
(
50
,
50
),
50
,
paint
);
canvas
.
rotate
(
1.0
);
}
canvas
.
restore
();
canvas
.
save
();
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
canvas
.
translate
(
1
,
1
);
canvas
.
clipRect
(
Rect
.
fromLTWH
(
20
,
20
,
40
/
i
,
40
));
canvas
.
drawRRect
(
RRect
.
fromRectAndRadius
(
const
Rect
.
fromLTWH
(
10
,
10
,
10
,
10
),
const
Radius
.
circular
(
2
)),
paint
);
canvas
.
drawParagraph
(
paragraph
,
Offset
.
zero
);
}
canvas
.
restore
();
}
});
profile
.
record
(
'estimatePaintBounds'
,
()
{
recorder
.
endRecording
();
});
}
}
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
View file @
54cdc26a
...
...
@@ -14,6 +14,7 @@ import 'src/web/bench_build_material_checkbox.dart';
import
'src/web/bench_card_infinite_scroll.dart'
;
import
'src/web/bench_draw_rect.dart'
;
import
'src/web/bench_dynamic_clip_on_static_picture.dart'
;
import
'src/web/bench_picture_recording.dart'
;
import
'src/web/bench_simple_lazy_text_scroll.dart'
;
import
'src/web/bench_text_out_of_picture_bounds.dart'
;
import
'src/web/recorder.dart'
;
...
...
@@ -33,6 +34,7 @@ final Map<String, RecorderFactory> benchmarks = <String, RecorderFactory>{
BenchSimpleLazyTextScroll
.
benchmarkName
:
()
=>
BenchSimpleLazyTextScroll
(),
BenchBuildMaterialCheckbox
.
benchmarkName
:
()
=>
BenchBuildMaterialCheckbox
(),
BenchDynamicClipOnStaticPicture
.
benchmarkName
:
()
=>
BenchDynamicClipOnStaticPicture
(),
BenchPictureRecording
.
benchmarkName
:
()
=>
BenchPictureRecording
(),
if
(
isCanvasKit
)
BenchBuildColorsGrid
.
canvasKitBenchmarkName
:
()
=>
BenchBuildColorsGrid
.
canvasKit
(),
...
...
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