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
4fea3ef5
Unverified
Commit
4fea3ef5
authored
May 18, 2023
by
joshualitt
Committed by
GitHub
May 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate benchmarks to package:web (#126848)
parent
2d6c67f4
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
125 additions
and
89 deletions
+125
-89
bench_image_decoding.dart
...rks/macrobenchmarks/lib/src/web/bench_image_decoding.dart
+8
-3
bench_platform_view_infinite_scroll.dart
...arks/lib/src/web/bench_platform_view_infinite_scroll.dart
+13
-11
recorder.dart
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
+17
-10
web_benchmarks.dart
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
+82
-63
pubspec.yaml
dev/benchmarks/macrobenchmarks/pubspec.yaml
+3
-1
pubspec.yaml
dev/devicelab/pubspec.yaml
+2
-1
No files found.
dev/benchmarks/macrobenchmarks/lib/src/web/bench_image_decoding.dart
View file @
4fea3ef5
...
...
@@ -2,10 +2,12 @@
// 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_interop'
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
import
'package:web/web.dart'
as
web
;
import
'recorder.dart'
;
// Measures the performance of image decoding.
...
...
@@ -43,8 +45,11 @@ class BenchImageDecoding extends RawRecorder {
return
;
}
for
(
final
String
imageUrl
in
_imageUrls
)
{
final
html
.
Body
image
=
await
html
.
window
.
fetch
(
imageUrl
)
as
html
.
Body
;
_imageData
.
add
((
await
image
.
arrayBuffer
()
as
ByteBuffer
).
asUint8List
());
final
Future
<
JSAny
?>
fetchFuture
=
web
.
window
.
fetch
(
imageUrl
.
toJS
).
toDart
;
final
web
.
Body
image
=
(
await
fetchFuture
)!
as
web
.
Body
;
final
Future
<
JSAny
?>
imageFuture
=
image
.
arrayBuffer
().
toDart
;
final
JSArrayBuffer
imageBuffer
=
(
await
imageFuture
)!
as
JSArrayBuffer
;
_imageData
.
add
(
imageBuffer
.
toDart
.
asUint8List
());
}
}
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_platform_view_infinite_scroll.dart
View file @
4fea3ef5
...
...
@@ -3,30 +3,32 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:
html'
as
html
;
import
'dart:
js_interop'
;
import
'package:flutter/material.dart'
;
import
'package:web/web.dart'
as
web
;
// TODO(mdebbar): flutter/flutter#55000 Remove this conditional import once
// web-only dart:ui_web APIs are exposed from a dedicated place.
import
'platform_views/non_web.dart'
if
(
dart
.
library
.
html
)
'platform_views/web.dart'
;
if
(
dart
.
library
.
js_interop
)
'platform_views/web.dart'
;
import
'recorder.dart'
;
const
String
benchmarkViewType
=
'benchmark_element'
;
void
_registerFactory
(
)
{
platformViewRegistry
.
registerViewFactory
(
benchmarkViewType
,
(
int
viewId
)
{
final
html
.
Element
htmlElement
=
html
.
DivElement
();
htmlElement
.
id
=
'
${benchmarkViewType}
_
$viewId
'
;
htmlElement
.
innerText
=
'Google'
;
final
web
.
HTMLElement
htmlElement
=
web
.
document
.
createElement
(
'div'
.
toJS
)
as
web
.
HTMLDivElement
;
htmlElement
.
id
=
'
${benchmarkViewType}
_
$viewId
'
.
toJS
;
htmlElement
.
innerText
=
'Google'
.
toJS
;
htmlElement
.
style
..
width
=
'100%'
..
height
=
'100%'
..
color
=
'black'
..
backgroundColor
=
'rgba(0, 255, 0, .5)'
..
textAlign
=
'center'
..
border
=
'1px solid black'
;
..
setProperty
(
'width'
.
toJS
,
'100%'
.
toJS
)
..
setProperty
(
'height'
.
toJS
,
'100%'
.
toJS
)
..
setProperty
(
'color'
.
toJS
,
'black'
.
toJS
)
..
setProperty
(
'backgroundColor'
.
toJS
,
'rgba(0, 255, 0, .5)'
.
toJS
)
..
setProperty
(
'textAlign'
.
toJS
,
'center'
.
toJS
)
..
setProperty
(
'border'
.
toJS
,
'1px solid black'
.
toJS
)
;
return
htmlElement
;
});
}
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
View file @
4fea3ef5
...
...
@@ -3,8 +3,11 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:html'
as
html
;
import
'dart:js_util'
as
js_util
;
import
'dart:js_interop'
;
// The analyzer currently thinks `js_interop_unsafe` is unused, but it is used
// for `JSObject.[]=`.
// ignore: unused_import
import
'dart:js_interop_unsafe'
;
import
'dart:math'
as
math
;
import
'dart:ui'
;
...
...
@@ -15,6 +18,7 @@ import 'package:flutter/scheduler.dart';
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:meta/meta.dart'
;
import
'package:web/web.dart'
as
web
;
/// The default number of samples from warm-up iterations.
///
...
...
@@ -1253,7 +1257,7 @@ void startMeasureFrame(Profile profile) {
if
(!
profile
.
isWarmingUp
)
{
// Tell the browser to mark the beginning of the frame.
html
.
window
.
performance
.
mark
(
'measured_frame_start#
$_currentFrameNumber
'
);
web
.
window
.
performance
.
mark
(
'measured_frame_start#
$_currentFrameNumber
'
.
toJS
);
_isMeasuringFrame
=
true
;
}
...
...
@@ -1276,11 +1280,11 @@ void endMeasureFrame() {
if
(
_isMeasuringFrame
)
{
// Tell the browser to mark the end of the frame, and measure the duration.
html
.
window
.
performance
.
mark
(
'measured_frame_end#
$_currentFrameNumber
'
);
html
.
window
.
performance
.
measure
(
'measured_frame'
,
'measured_frame_start#
$_currentFrameNumber
'
,
'measured_frame_end#
$_currentFrameNumber
'
,
web
.
window
.
performance
.
mark
(
'measured_frame_end#
$_currentFrameNumber
'
.
toJS
);
web
.
window
.
performance
.
measure
(
'measured_frame'
.
toJS
,
'measured_frame_start#
$_currentFrameNumber
'
.
toJS
,
'measured_frame_end#
$_currentFrameNumber
'
.
toJS
,
);
// Increment the current frame number.
...
...
@@ -1310,7 +1314,10 @@ void registerEngineBenchmarkValueListener(String name, EngineBenchmarkValueListe
if
(
_engineBenchmarkListeners
.
isEmpty
)
{
// The first listener is being registered. Register the global listener.
js_util
.
setProperty
(
html
.
window
,
'_flutter_internal_on_benchmark'
,
_dispatchEngineBenchmarkValue
);
web
.
window
[
'_flutter_internal_on_benchmark'
.
toJS
]
=
// Upcast to [Object] to export.
// ignore: unnecessary_cast
(
_dispatchEngineBenchmarkValue
as
Object
).
toJS
;
}
_engineBenchmarkListeners
[
name
]
=
listener
;
...
...
@@ -1321,7 +1328,7 @@ void stopListeningToEngineBenchmarkValues(String name) {
_engineBenchmarkListeners
.
remove
(
name
);
if
(
_engineBenchmarkListeners
.
isEmpty
)
{
// The last listener unregistered. Remove the global listener.
js_util
.
setProperty
(
html
.
window
,
'_flutter_internal_on_benchmark'
,
null
)
;
web
.
window
[
'_flutter_internal_on_benchmark'
.
toJS
]
=
null
;
}
}
...
...
dev/benchmarks/macrobenchmarks/lib/web_benchmarks.dart
View file @
4fea3ef5
This diff is collapsed.
Click to expand it.
dev/benchmarks/macrobenchmarks/pubspec.yaml
View file @
4fea3ef5
...
...
@@ -18,6 +18,8 @@ dependencies:
# flutter update-packages --force-upgrade
flutter_gallery_assets
:
1.0.2
web
:
0.1.2-beta
async
:
2.11.0
# THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector
:
2.1.1
# THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
characters
:
1.3.0
# THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...
...
@@ -209,4 +211,4 @@ flutter:
fonts
:
-
asset
:
packages/flutter_gallery_assets/fonts/GalleryIcons.ttf
# PUBSPEC CHECKSUM:
1586
# PUBSPEC CHECKSUM:
fdda
dev/devicelab/pubspec.yaml
View file @
4fea3ef5
...
...
@@ -21,6 +21,7 @@ dependencies:
shelf_static
:
1.1.2
stack_trace
:
1.11.0
vm_service
:
11.6.0
web
:
0.1.2-beta
webkit_inspection_protocol
:
1.2.0
_discoveryapis_commons
:
1.0.5
# THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...
...
@@ -69,4 +70,4 @@ dev_dependencies:
watcher
:
1.1.0
# THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
web_socket_channel
:
2.4.0
# THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
# PUBSPEC CHECKSUM:
022d
# PUBSPEC CHECKSUM:
f681
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