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
c2f6a3af
Unverified
Commit
c2f6a3af
authored
Dec 06, 2021
by
Mouad Debbar
Committed by
GitHub
Dec 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] Stop using web experiments in benchmarks (#94739)
parent
1aabe314
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
63 deletions
+5
-63
bench_text_layout.dart
...hmarks/macrobenchmarks/lib/src/web/bench_text_layout.dart
+5
-60
web_benchmarks.dart
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
+0
-3
No files found.
dev/benchmarks/macrobenchmarks/lib/src/web/bench_text_layout.dart
View file @
c2f6a3af
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:html'
as
html
;
import
'dart:js_util'
as
js_util
;
import
'dart:math'
;
import
'dart:ui'
as
ui
;
...
...
@@ -52,59 +50,25 @@ enum _TestMode {
/// Uses the HTML rendering backend with the canvas 2D text layout.
useCanvasTextLayout
,
/// Uses the HTML rendering backend with the DOM text layout.
useDomTextLayout
,
/// Uses CanvasKit for everything.
useCanvasKit
,
}
/// Sends a platform message to the web engine to enable/disable the usage of
/// the canvas-based text measurement implementation.
void
_setTestMode
(
_TestMode
?
mode
)
{
bool
?
useCanvasText
;
// null means do not force DOM or canvas, works for CanvasKit
switch
(
mode
)
{
case
_TestMode
.
useDomTextLayout
:
useCanvasText
=
false
;
break
;
case
_TestMode
.
useCanvasTextLayout
:
useCanvasText
=
true
;
break
;
case
_TestMode
.
useCanvasKit
:
case
null
:
// Keep as null.
break
;
}
// ignore: implicit_dynamic_function
js_util
.
callMethod
(
html
.
window
,
'_flutter_internal_update_experiment'
,
<
dynamic
>[
'useCanvasText'
,
useCanvasText
],
);
}
/// Repeatedly lays out a paragraph.
///
/// Creates a different paragraph each time in order to avoid hitting the cache.
class
BenchTextLayout
extends
RawRecorder
{
BenchTextLayout
.
dom
()
:
_mode
=
_TestMode
.
useDomTextLayout
,
super
(
name:
domBenchmarkName
);
BenchTextLayout
.
canvas
()
:
_mode
=
_TestMode
.
useCanvasTextLayout
,
super
(
name:
canvasBenchmarkName
);
:
super
(
name:
canvasBenchmarkName
);
BenchTextLayout
.
canvasKit
()
:
_mode
=
_TestMode
.
useCanvasKit
,
super
(
name:
canvasKitBenchmarkName
);
:
super
(
name:
canvasKitBenchmarkName
);
static
const
String
domBenchmarkName
=
'text_dom_layout'
;
static
const
String
canvasBenchmarkName
=
'text_canvas_layout'
;
static
const
String
canvasKitBenchmarkName
=
'text_canvaskit_layout'
;
final
ParagraphGenerator
generator
=
ParagraphGenerator
();
/// Whether to use the new canvas-based text measurement implementation.
final
_TestMode
_mode
;
static
const
String
singleLineText
=
'*** ** ****'
;
static
const
String
multiLineText
=
'*** ****** **** *** ******** * *** '
'******* **** ********** *** ******* '
...
...
@@ -113,8 +77,6 @@ class BenchTextLayout extends RawRecorder {
@override
void
body
(
Profile
profile
)
{
_setTestMode
(
_mode
);
recordParagraphOperations
(
profile:
profile
,
paragraph:
generator
.
generate
(
singleLineText
),
...
...
@@ -146,8 +108,6 @@ class BenchTextLayout extends RawRecorder {
keyPrefix:
'ellipsis'
,
maxWidth:
200.0
,
);
_setTestMode
(
null
);
}
void
recordParagraphOperations
({
...
...
@@ -183,25 +143,17 @@ class BenchTextLayout extends RawRecorder {
/// use the same paragraph instance because the layout method will shortcircuit
/// in that case.
class
BenchTextCachedLayout
extends
RawRecorder
{
BenchTextCachedLayout
.
dom
()
:
_mode
=
_TestMode
.
useDomTextLayout
,
super
(
name:
domBenchmarkName
);
BenchTextCachedLayout
.
canvas
()
:
_mode
=
_TestMode
.
useCanvasTextLayout
,
super
(
name:
canvasBenchmarkName
);
:
super
(
name:
canvasBenchmarkName
);
BenchTextCachedLayout
.
canvasKit
()
:
_mode
=
_TestMode
.
useCanvasKit
,
super
(
name:
canvasKitBenchmarkName
);
:
super
(
name:
canvasKitBenchmarkName
);
static
const
String
domBenchmarkName
=
'text_dom_cached_layout'
;
static
const
String
canvasBenchmarkName
=
'text_canvas_cached_layout'
;
static
const
String
canvasKitBenchmarkName
=
'text_canvas_kit_cached_layout'
;
/// Whether to use the new canvas-based text measurement implementation.
final
_TestMode
_mode
;
@override
void
body
(
Profile
profile
)
{
_setTestMode
(
_mode
);
final
ui
.
ParagraphBuilder
builder
=
ui
.
ParagraphBuilder
(
ui
.
ParagraphStyle
(
fontFamily:
'sans-serif'
))
..
pushStyle
(
ui
.
TextStyle
(
fontSize:
12.0
))
..
addText
(
...
...
@@ -212,7 +164,6 @@ class BenchTextCachedLayout extends RawRecorder {
profile
.
record
(
'layout'
,
()
{
paragraph
.
layout
(
const
ui
.
ParagraphConstraints
(
width:
double
.
infinity
));
},
reported:
true
);
_setTestMode
(
null
);
}
}
...
...
@@ -230,8 +181,7 @@ int _counter = 0;
class
BenchBuildColorsGrid
extends
WidgetBuildRecorder
{
BenchBuildColorsGrid
.
canvas
()
:
_mode
=
_TestMode
.
useCanvasTextLayout
,
super
(
name:
canvasBenchmarkName
);
BenchBuildColorsGrid
.
dom
()
:
_mode
=
_TestMode
.
useDomTextLayout
,
super
(
name:
domBenchmarkName
);
BenchBuildColorsGrid
.
canvasKit
()
:
_mode
=
_TestMode
.
useCanvasKit
,
super
(
name:
canvasKitBenchmarkName
);
...
...
@@ -240,12 +190,9 @@ class BenchBuildColorsGrid extends WidgetBuildRecorder {
/// When tracing is enabled, DOM layout takes longer to complete. This has a
/// significant effect on the benchmark since we do a lot of text layout
/// operations that trigger synchronous DOM layout.
///
/// Tracing has a negative effect only in [_TestMode.useDomTextLayout] mode.
@override
bool
get
isTracingEnabled
=>
false
;
static
const
String
domBenchmarkName
=
'text_dom_color_grid'
;
static
const
String
canvasBenchmarkName
=
'text_canvas_color_grid'
;
static
const
String
canvasKitBenchmarkName
=
'text_canvas_kit_color_grid'
;
...
...
@@ -256,7 +203,6 @@ class BenchBuildColorsGrid extends WidgetBuildRecorder {
@override
Future
<
void
>
setUpAll
()
async
{
_setTestMode
(
_mode
);
registerEngineBenchmarkValueListener
(
'text_layout'
,
(
num
value
)
{
_textLayoutMicros
+=
value
;
});
...
...
@@ -264,7 +210,6 @@ class BenchBuildColorsGrid extends WidgetBuildRecorder {
@override
Future
<
void
>
tearDownAll
()
async
{
_setTestMode
(
null
);
stopListeningToEngineBenchmarkValues
(
'text_layout'
);
}
...
...
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
View file @
c2f6a3af
...
...
@@ -72,11 +72,8 @@ final Map<String, RecorderFactory> benchmarks = <String, RecorderFactory>{
// HTML-only benchmarks
if
(!
isCanvasKit
)
...<
String
,
RecorderFactory
>{
BenchTextLayout
.
domBenchmarkName
:
()
=>
BenchTextLayout
.
dom
(),
BenchTextLayout
.
canvasBenchmarkName
:
()
=>
BenchTextLayout
.
canvas
(),
BenchTextCachedLayout
.
domBenchmarkName
:
()
=>
BenchTextCachedLayout
.
dom
(),
BenchTextCachedLayout
.
canvasBenchmarkName
:
()
=>
BenchTextCachedLayout
.
canvas
(),
BenchBuildColorsGrid
.
domBenchmarkName
:
()
=>
BenchBuildColorsGrid
.
dom
(),
BenchBuildColorsGrid
.
canvasBenchmarkName
:
()
=>
BenchBuildColorsGrid
.
canvas
(),
},
};
...
...
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