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
5bb55227
Unverified
Commit
5bb55227
authored
Mar 11, 2020
by
Mouad Debbar
Committed by
GitHub
Mar 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] Add benchmarks for text layout (#51663)
parent
fc5350ed
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
342 additions
and
185 deletions
+342
-185
bench_draw_rect.dart
...nchmarks/macrobenchmarks/lib/src/web/bench_draw_rect.dart
+1
-1
bench_text_layout.dart
...hmarks/macrobenchmarks/lib/src/web/bench_text_layout.dart
+65
-0
bench_text_out_of_picture_bounds.dart
...chmarks/lib/src/web/bench_text_out_of_picture_bounds.dart
+1
-1
recorder.dart
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
+266
-179
web_benchmarks.dart
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
+9
-0
web_benchmarks.dart
dev/devicelab/lib/tasks/web_benchmarks.dart
+0
-4
No files found.
dev/benchmarks/macrobenchmarks/lib/src/web/bench_draw_rect.dart
View file @
5bb55227
...
@@ -9,7 +9,7 @@ import 'recorder.dart';
...
@@ -9,7 +9,7 @@ import 'recorder.dart';
/// Repeatedly paints a grid of rectangles.
/// Repeatedly paints a grid of rectangles.
///
///
/// Measures the performance of the `drawRect` operation.
/// Measures the performance of the `drawRect` operation.
class
BenchDrawRect
extends
Raw
Recorder
{
class
BenchDrawRect
extends
SceneBuilder
Recorder
{
BenchDrawRect
()
:
super
(
name:
benchmarkName
);
BenchDrawRect
()
:
super
(
name:
benchmarkName
);
static
const
String
benchmarkName
=
'draw_rect'
;
static
const
String
benchmarkName
=
'draw_rect'
;
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_text_layout.dart
0 → 100644
View file @
5bb55227
// 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
'recorder.dart'
;
int
_counter
=
0
;
Paragraph
_generateParagraph
(
)
{
final
ParagraphBuilder
builder
=
ParagraphBuilder
(
ParagraphStyle
(
fontFamily:
'sans-serif'
))
..
pushStyle
(
TextStyle
(
fontSize:
12.0
))
..
addText
(
'
$_counter
Lorem ipsum dolor sit amet, consectetur adipiscing elit, '
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
,
);
_counter
++;
return
builder
.
build
();
}
/// Repeatedly lays out a paragraph using the DOM measurement approach.
///
/// Creates a different paragraph each time in order to avoid hitting the cache.
class
BenchTextDomLayout
extends
RawRecorder
{
BenchTextDomLayout
()
:
super
(
name:
benchmarkName
);
static
const
String
benchmarkName
=
'text_dom_layout'
;
@override
void
body
(
Profile
profile
)
{
final
Paragraph
paragraph
=
_generateParagraph
();
profile
.
record
(
'layout'
,
()
{
paragraph
.
layout
(
const
ParagraphConstraints
(
width:
double
.
infinity
));
});
}
}
/// Repeatedly lays out a paragraph using the DOM measurement approach.
///
/// Uses the same paragraph content to make sure we hit the cache. It doesn't
/// use the same paragraph instance because the layout method will shortcircuit
/// in that case.
class
BenchTextDomCachedLayout
extends
RawRecorder
{
BenchTextDomCachedLayout
()
:
super
(
name:
benchmarkName
);
static
const
String
benchmarkName
=
'text_dom_cached_layout'
;
final
ParagraphBuilder
builder
=
ParagraphBuilder
(
ParagraphStyle
(
fontFamily:
'sans-serif'
))
..
pushStyle
(
TextStyle
(
fontSize:
12.0
))
..
addText
(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, '
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
,
);
@override
void
body
(
Profile
profile
)
{
final
Paragraph
paragraph
=
builder
.
build
();
profile
.
record
(
'layout'
,
()
{
paragraph
.
layout
(
const
ParagraphConstraints
(
width:
double
.
infinity
));
});
}
}
dev/benchmarks/macrobenchmarks/lib/src/web/bench_text_out_of_picture_bounds.dart
View file @
5bb55227
...
@@ -27,7 +27,7 @@ import 'test_data.dart';
...
@@ -27,7 +27,7 @@ import 'test_data.dart';
///
///
/// This reproduces the bug where we render more than visible causing
/// This reproduces the bug where we render more than visible causing
/// performance issues: https://github.com/flutter/flutter/issues/48516
/// performance issues: https://github.com/flutter/flutter/issues/48516
class
BenchTextOutOfPictureBounds
extends
Raw
Recorder
{
class
BenchTextOutOfPictureBounds
extends
SceneBuilder
Recorder
{
BenchTextOutOfPictureBounds
()
:
super
(
name:
benchmarkName
)
{
BenchTextOutOfPictureBounds
()
:
super
(
name:
benchmarkName
)
{
const
Color
red
=
Color
.
fromARGB
(
255
,
255
,
0
,
0
);
const
Color
red
=
Color
.
fromARGB
(
255
,
255
,
0
,
0
);
const
Color
green
=
Color
.
fromARGB
(
255
,
0
,
255
,
0
);
const
Color
green
=
Color
.
fromARGB
(
255
,
0
,
255
,
0
);
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
View file @
5bb55227
This diff is collapsed.
Click to expand it.
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
View file @
5bb55227
...
@@ -6,6 +6,7 @@ import 'dart:async';
...
@@ -6,6 +6,7 @@ import 'dart:async';
import
'dart:convert'
show
json
;
import
'dart:convert'
show
json
;
import
'dart:html'
as
html
;
import
'dart:html'
as
html
;
import
'package:macrobenchmarks/src/web/bench_text_layout.dart'
;
import
'package:macrobenchmarks/src/web/bench_text_out_of_picture_bounds.dart'
;
import
'package:macrobenchmarks/src/web/bench_text_out_of_picture_bounds.dart'
;
import
'src/web/bench_build_material_checkbox.dart'
;
import
'src/web/bench_build_material_checkbox.dart'
;
...
@@ -17,6 +18,8 @@ import 'src/web/recorder.dart';
...
@@ -17,6 +18,8 @@ import 'src/web/recorder.dart';
typedef
RecorderFactory
=
Recorder
Function
();
typedef
RecorderFactory
=
Recorder
Function
();
const
bool
isCanvasKit
=
bool
.
fromEnvironment
(
'FLUTTER_WEB_USE_SKIA'
,
defaultValue:
false
);
/// List of all benchmarks that run in the devicelab.
/// List of all benchmarks that run in the devicelab.
///
///
/// 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
...
@@ -27,6 +30,12 @@ final Map<String, RecorderFactory> benchmarks = <String, RecorderFactory>{
...
@@ -27,6 +30,12 @@ final Map<String, RecorderFactory> benchmarks = <String, RecorderFactory>{
BenchTextOutOfPictureBounds
.
benchmarkName
:
()
=>
BenchTextOutOfPictureBounds
(),
BenchTextOutOfPictureBounds
.
benchmarkName
:
()
=>
BenchTextOutOfPictureBounds
(),
BenchSimpleLazyTextScroll
.
benchmarkName
:
()
=>
BenchSimpleLazyTextScroll
(),
BenchSimpleLazyTextScroll
.
benchmarkName
:
()
=>
BenchSimpleLazyTextScroll
(),
BenchBuildMaterialCheckbox
.
benchmarkName
:
()
=>
BenchBuildMaterialCheckbox
(),
BenchBuildMaterialCheckbox
.
benchmarkName
:
()
=>
BenchBuildMaterialCheckbox
(),
// Benchmarks that we don't want to run using CanvasKit.
if
(!
isCanvasKit
)
...<
String
,
RecorderFactory
>{
BenchTextDomLayout
.
benchmarkName
:
()
=>
BenchTextDomLayout
(),
BenchTextDomCachedLayout
.
benchmarkName
:
()
=>
BenchTextDomCachedLayout
(),
}
};
};
/// Whether we fell back to manual mode.
/// Whether we fell back to manual mode.
...
...
dev/devicelab/lib/tasks/web_benchmarks.dart
View file @
5bb55227
...
@@ -138,10 +138,6 @@ Future<TaskResult> runWebBenchmark({ @required bool useCanvasKit }) async {
...
@@ -138,10 +138,6 @@ Future<TaskResult> runWebBenchmark({ @required bool useCanvasKit }) async {
throw
'Score key is empty in benchmark "
$benchmarkName
". '
throw
'Score key is empty in benchmark "
$benchmarkName
". '
'Received [
${scoreKeys.join(', ')}
]'
;
'Received [
${scoreKeys.join(', ')}
]'
;
}
}
if
(
scoreKey
.
contains
(
'.'
))
{
throw
'Score key contain dots in benchmark "
$benchmarkName
". '
'Received [
${scoreKeys.join(', ')}
]'
;
}
benchmarkScoreKeys
.
add
(
'
$namespace
.
$scoreKey
'
);
benchmarkScoreKeys
.
add
(
'
$namespace
.
$scoreKey
'
);
}
}
...
...
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