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
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 @@
...
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'dart:
html'
as
html
;
import
'dart:
js_interop'
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
import
'dart:ui'
as
ui
;
import
'package:web/web.dart'
as
web
;
import
'recorder.dart'
;
import
'recorder.dart'
;
// Measures the performance of image decoding.
// Measures the performance of image decoding.
...
@@ -43,8 +45,11 @@ class BenchImageDecoding extends RawRecorder {
...
@@ -43,8 +45,11 @@ class BenchImageDecoding extends RawRecorder {
return
;
return
;
}
}
for
(
final
String
imageUrl
in
_imageUrls
)
{
for
(
final
String
imageUrl
in
_imageUrls
)
{
final
html
.
Body
image
=
await
html
.
window
.
fetch
(
imageUrl
)
as
html
.
Body
;
final
Future
<
JSAny
?>
fetchFuture
=
web
.
window
.
fetch
(
imageUrl
.
toJS
).
toDart
;
_imageData
.
add
((
await
image
.
arrayBuffer
()
as
ByteBuffer
).
asUint8List
());
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 @@
...
@@ -3,30 +3,32 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:async'
;
import
'dart:
html'
as
html
;
import
'dart:
js_interop'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:web/web.dart'
as
web
;
// TODO(mdebbar): flutter/flutter#55000 Remove this conditional import once
// TODO(mdebbar): flutter/flutter#55000 Remove this conditional import once
// web-only dart:ui_web APIs are exposed from a dedicated place.
// web-only dart:ui_web APIs are exposed from a dedicated place.
import
'platform_views/non_web.dart'
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'
;
import
'recorder.dart'
;
const
String
benchmarkViewType
=
'benchmark_element'
;
const
String
benchmarkViewType
=
'benchmark_element'
;
void
_registerFactory
(
)
{
void
_registerFactory
(
)
{
platformViewRegistry
.
registerViewFactory
(
benchmarkViewType
,
(
int
viewId
)
{
platformViewRegistry
.
registerViewFactory
(
benchmarkViewType
,
(
int
viewId
)
{
final
html
.
Element
htmlElement
=
html
.
DivElement
();
final
web
.
HTMLElement
htmlElement
=
web
.
document
.
createElement
(
'div'
.
toJS
)
htmlElement
.
id
=
'
${benchmarkViewType}
_
$viewId
'
;
as
web
.
HTMLDivElement
;
htmlElement
.
innerText
=
'Google'
;
htmlElement
.
id
=
'
${benchmarkViewType}
_
$viewId
'
.
toJS
;
htmlElement
.
innerText
=
'Google'
.
toJS
;
htmlElement
.
style
htmlElement
.
style
..
width
=
'100%'
..
setProperty
(
'width'
.
toJS
,
'100%'
.
toJS
)
..
height
=
'100%'
..
setProperty
(
'height'
.
toJS
,
'100%'
.
toJS
)
..
color
=
'black'
..
setProperty
(
'color'
.
toJS
,
'black'
.
toJS
)
..
backgroundColor
=
'rgba(0, 255, 0, .5)'
..
setProperty
(
'backgroundColor'
.
toJS
,
'rgba(0, 255, 0, .5)'
.
toJS
)
..
textAlign
=
'center'
..
setProperty
(
'textAlign'
.
toJS
,
'center'
.
toJS
)
..
border
=
'1px solid black'
;
..
setProperty
(
'border'
.
toJS
,
'1px solid black'
.
toJS
)
;
return
htmlElement
;
return
htmlElement
;
});
});
}
}
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
View file @
4fea3ef5
...
@@ -3,8 +3,11 @@
...
@@ -3,8 +3,11 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:async'
;
import
'dart:html'
as
html
;
import
'dart:js_interop'
;
import
'dart:js_util'
as
js_util
;
// 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:math'
as
math
;
import
'dart:ui'
;
import
'dart:ui'
;
...
@@ -15,6 +18,7 @@ import 'package:flutter/scheduler.dart';
...
@@ -15,6 +18,7 @@ import 'package:flutter/scheduler.dart';
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'package:web/web.dart'
as
web
;
/// The default number of samples from warm-up iterations.
/// The default number of samples from warm-up iterations.
///
///
...
@@ -1253,7 +1257,7 @@ void startMeasureFrame(Profile profile) {
...
@@ -1253,7 +1257,7 @@ void startMeasureFrame(Profile profile) {
if
(!
profile
.
isWarmingUp
)
{
if
(!
profile
.
isWarmingUp
)
{
// Tell the browser to mark the beginning of the frame.
// 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
;
_isMeasuringFrame
=
true
;
}
}
...
@@ -1276,11 +1280,11 @@ void endMeasureFrame() {
...
@@ -1276,11 +1280,11 @@ void endMeasureFrame() {
if
(
_isMeasuringFrame
)
{
if
(
_isMeasuringFrame
)
{
// Tell the browser to mark the end of the frame, and measure the duration.
// Tell the browser to mark the end of the frame, and measure the duration.
html
.
window
.
performance
.
mark
(
'measured_frame_end#
$_currentFrameNumber
'
);
web
.
window
.
performance
.
mark
(
'measured_frame_end#
$_currentFrameNumber
'
.
toJS
);
html
.
window
.
performance
.
measure
(
web
.
window
.
performance
.
measure
(
'measured_frame'
,
'measured_frame'
.
toJS
,
'measured_frame_start#
$_currentFrameNumber
'
,
'measured_frame_start#
$_currentFrameNumber
'
.
toJS
,
'measured_frame_end#
$_currentFrameNumber
'
,
'measured_frame_end#
$_currentFrameNumber
'
.
toJS
,
);
);
// Increment the current frame number.
// Increment the current frame number.
...
@@ -1310,7 +1314,10 @@ void registerEngineBenchmarkValueListener(String name, EngineBenchmarkValueListe
...
@@ -1310,7 +1314,10 @@ void registerEngineBenchmarkValueListener(String name, EngineBenchmarkValueListe
if
(
_engineBenchmarkListeners
.
isEmpty
)
{
if
(
_engineBenchmarkListeners
.
isEmpty
)
{
// The first listener is being registered. Register the global listener.
// 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
;
_engineBenchmarkListeners
[
name
]
=
listener
;
...
@@ -1321,7 +1328,7 @@ void stopListeningToEngineBenchmarkValues(String name) {
...
@@ -1321,7 +1328,7 @@ void stopListeningToEngineBenchmarkValues(String name) {
_engineBenchmarkListeners
.
remove
(
name
);
_engineBenchmarkListeners
.
remove
(
name
);
if
(
_engineBenchmarkListeners
.
isEmpty
)
{
if
(
_engineBenchmarkListeners
.
isEmpty
)
{
// The last listener unregistered. Remove the global listener.
// 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
...
@@ -4,9 +4,11 @@
...
@@ -4,9 +4,11 @@
import
'dart:async'
;
import
'dart:async'
;
import
'dart:convert'
show
json
;
import
'dart:convert'
show
json
;
import
'dart:
html'
as
html
;
import
'dart:
js_interop'
;
import
'dart:math'
as
math
;
import
'dart:math'
as
math
;
import
'package:web/web.dart'
as
web
;
import
'src/web/bench_build_image.dart'
;
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'
;
...
@@ -95,7 +97,7 @@ Future<void> main() async {
...
@@ -95,7 +97,7 @@ Future<void> main() async {
}
}
await
_runBenchmark
(
nextBenchmark
);
await
_runBenchmark
(
nextBenchmark
);
html
.
window
.
location
.
reload
();
web
.
window
.
location
.
reload
();
}
}
Future
<
void
>
_runBenchmark
(
String
benchmarkName
)
async
{
Future
<
void
>
_runBenchmark
(
String
benchmarkName
)
async
{
...
@@ -150,8 +152,20 @@ Future<void> _runBenchmark(String benchmarkName) async {
...
@@ -150,8 +152,20 @@ Future<void> _runBenchmark(String benchmarkName) async {
);
);
}
}
extension
WebHTMLElementExtension
on
web
.
HTMLElement
{
void
appendHtml
(
String
html
)
{
final
web
.
HTMLDivElement
div
=
web
.
document
.
createElement
(
'div'
.
toJS
)
as
web
.
HTMLDivElement
;
div
.
innerHTML
=
html
.
toJS
;
final
web
.
DocumentFragment
fragment
=
web
.
document
.
createDocumentFragment
();
fragment
.
append
(
div
);
web
.
document
.
adoptNode
(
fragment
);
append
(
fragment
);
}
}
void
_fallbackToManual
(
String
error
)
{
void
_fallbackToManual
(
String
error
)
{
html
.
document
.
body
!.
appendHtml
(
'''
web
.
document
.
body
!.
appendHtml
(
'''
<div id="manual-panel">
<div id="manual-panel">
<h3>
$error
</h3>
<h3>
$error
</h3>
...
@@ -166,28 +180,29 @@ void _fallbackToManual(String error) {
...
@@ -166,28 +180,29 @@ void _fallbackToManual(String error) {
}
}
</ul>
</ul>
</div>
</div>
'''
,
validator:
html
.
NodeValidatorBuilder
()..
allowHtml5
()..
allowInlineStyles
()
);
'''
);
for
(
final
String
benchmarkName
in
benchmarks
.
keys
)
{
for
(
final
String
benchmarkName
in
benchmarks
.
keys
)
{
final
html
.
Element
button
=
html
.
document
.
querySelector
(
'#
$benchmarkName
'
)!;
final
web
.
Element
button
=
web
.
document
.
querySelector
(
'#
$benchmarkName
'
.
toJS
)!;
button
.
addEventListener
(
'click'
,
(
_
)
{
button
.
addEventListener
(
'click'
.
toJS
,
(
JSObject
_
)
{
final
html
.
Element
?
manualPanel
=
html
.
document
.
querySelector
(
'#manual-panel'
);
final
web
.
Element
?
manualPanel
=
web
.
document
.
querySelector
(
'#manual-panel'
.
toJS
);
manualPanel
?.
remove
();
manualPanel
?.
remove
();
_runBenchmark
(
benchmarkName
);
_runBenchmark
(
benchmarkName
);
});
}
.
toJS
);
}
}
}
}
/// Visualizes results on the Web page for manual inspection.
/// Visualizes results on the Web page for manual inspection.
void
_printResultsToScreen
(
Profile
profile
)
{
void
_printResultsToScreen
(
Profile
profile
)
{
html
.
document
.
body
!.
remove
();
web
.
document
.
body
!.
remove
();
html
.
document
.
body
=
html
.
BodyElement
()
;
web
.
document
.
body
=
web
.
document
.
createElement
(
'body'
.
toJS
)
as
web
.
HTMLBodyElement
;
html
.
document
.
body
!.
appendHtml
(
'<h2>
${profile.name}
</h2>'
);
web
.
document
.
body
!.
appendHtml
(
'<h2>
${profile.name}
</h2>'
);
profile
.
scoreData
.
forEach
((
String
scoreKey
,
Timeseries
timeseries
)
{
profile
.
scoreData
.
forEach
((
String
scoreKey
,
Timeseries
timeseries
)
{
html
.
document
.
body
!.
appendHtml
(
'<h2>
$scoreKey
</h2>'
);
web
.
document
.
body
!.
appendHtml
(
'<h2>
$scoreKey
</h2>'
);
html
.
document
.
body
!.
appendHtml
(
'<pre>
${timeseries.computeStats()}
</pre>'
);
web
.
document
.
body
!.
appendHtml
(
'<pre>
${timeseries.computeStats()}
</pre>'
);
html
.
document
.
body
!.
append
(
TimeseriesVisualization
(
timeseries
).
render
());
web
.
document
.
body
!.
append
(
TimeseriesVisualization
(
timeseries
).
render
());
});
});
}
}
...
@@ -195,15 +210,15 @@ void _printResultsToScreen(Profile profile) {
...
@@ -195,15 +210,15 @@ void _printResultsToScreen(Profile profile) {
class
TimeseriesVisualization
{
class
TimeseriesVisualization
{
TimeseriesVisualization
(
this
.
_timeseries
)
{
TimeseriesVisualization
(
this
.
_timeseries
)
{
_stats
=
_timeseries
.
computeStats
();
_stats
=
_timeseries
.
computeStats
();
_canvas
=
html
.
CanvasElement
()
;
_canvas
=
web
.
document
.
createElement
(
'canvas'
.
toJS
)
as
web
.
HTMLCanvasElement
;
_screenWidth
=
html
.
window
.
screen
!.
width
!
;
_screenWidth
=
web
.
window
.
screen
.
width
.
toDart
.
toInt
()
;
_canvas
.
width
=
_screenWidth
;
_canvas
.
width
=
_screenWidth
.
toJS
;
_canvas
.
height
=
(
_kCanvasHeight
*
html
.
window
.
devicePixelRatio
).
round
()
;
_canvas
.
height
=
(
_kCanvasHeight
*
web
.
window
.
devicePixelRatio
.
toDart
).
round
().
toJS
;
_canvas
.
style
_canvas
.
style
..
width
=
'100%'
..
setProperty
(
'width'
.
toJS
,
'100%'
.
toJS
)
..
height
=
'
${_kCanvasHeight}
px'
..
setProperty
(
'height'
.
toJS
,
'
${_kCanvasHeight}
px'
.
toJS
)
..
outline
=
'1px solid green'
;
..
setProperty
(
'outline'
.
toJS
,
'1px solid green'
.
toJS
)
;
_ctx
=
_canvas
.
c
ontext2D
;
_ctx
=
_canvas
.
getContext
(
'2d'
.
toJS
)!
as
web
.
CanvasRenderingC
ontext2D
;
// The amount of vertical space available on the chart. Because some
// The amount of vertical space available on the chart. Because some
// outliers can be huge they can dwarf all the useful values. So we
// outliers can be huge they can dwarf all the useful values. So we
...
@@ -218,8 +233,8 @@ class TimeseriesVisualization {
...
@@ -218,8 +233,8 @@ class TimeseriesVisualization {
final
Timeseries
_timeseries
;
final
Timeseries
_timeseries
;
late
TimeseriesStats
_stats
;
late
TimeseriesStats
_stats
;
late
html
.
CanvasElement
_canvas
;
late
web
.
HTML
CanvasElement
_canvas
;
late
html
.
CanvasRenderingContext2D
_ctx
;
late
web
.
CanvasRenderingContext2D
_ctx
;
late
int
_screenWidth
;
late
int
_screenWidth
;
// Used to normalize benchmark values to chart height.
// Used to normalize benchmark values to chart height.
...
@@ -235,15 +250,15 @@ class TimeseriesVisualization {
...
@@ -235,15 +250,15 @@ class TimeseriesVisualization {
/// A utility for drawing lines.
/// A utility for drawing lines.
void
drawLine
(
num
x1
,
num
y1
,
num
x2
,
num
y2
)
{
void
drawLine
(
num
x1
,
num
y1
,
num
x2
,
num
y2
)
{
_ctx
.
beginPath
();
_ctx
.
beginPath
();
_ctx
.
moveTo
(
x1
,
y1
);
_ctx
.
moveTo
(
x1
.
toJS
,
y1
.
toJS
);
_ctx
.
lineTo
(
x2
,
y2
);
_ctx
.
lineTo
(
x2
.
toJS
,
y2
.
toJS
);
_ctx
.
stroke
();
_ctx
.
stroke
();
}
}
/// Renders the timeseries into a `<canvas>` and returns the canvas element.
/// Renders the timeseries into a `<canvas>` and returns the canvas element.
html
.
CanvasElement
render
()
{
web
.
HTML
CanvasElement
render
()
{
_ctx
.
translate
(
0
,
_kCanvasHeight
*
html
.
window
.
devicePixelRatio
);
_ctx
.
translate
(
0
.
toJS
,
(
_kCanvasHeight
*
web
.
window
.
devicePixelRatio
.
toDart
).
toJS
);
_ctx
.
scale
(
1
,
-
html
.
window
.
devicePixelRatio
);
_ctx
.
scale
(
1
.
toJS
,
(-
web
.
window
.
devicePixelRatio
.
toDart
).
toJS
);
final
double
barWidth
=
_screenWidth
/
_stats
.
samples
.
length
;
final
double
barWidth
=
_screenWidth
/
_stats
.
samples
.
length
;
double
xOffset
=
0
;
double
xOffset
=
0
;
...
@@ -252,40 +267,42 @@ class TimeseriesVisualization {
...
@@ -252,40 +267,42 @@ class TimeseriesVisualization {
if
(
sample
.
isWarmUpValue
)
{
if
(
sample
.
isWarmUpValue
)
{
// Put gray background behind warm-up samples.
// Put gray background behind warm-up samples.
_ctx
.
fillStyle
=
'rgba(200,200,200,1)'
;
_ctx
.
fillStyle
=
'rgba(200,200,200,1)'
.
toJS
;
_ctx
.
fillRect
(
xOffset
,
0
,
barWidth
,
_normalized
(
_maxValueChartRange
));
_ctx
.
fillRect
(
xOffset
.
toJS
,
0
.
toJS
,
barWidth
.
toJS
,
_normalized
(
_maxValueChartRange
).
toJS
);
}
}
if
(
sample
.
magnitude
>
_maxValueChartRange
)
{
if
(
sample
.
magnitude
>
_maxValueChartRange
)
{
// The sample value is so big it doesn't fit on the chart. Paint it purple.
// The sample value is so big it doesn't fit on the chart. Paint it purple.
_ctx
.
fillStyle
=
'rgba(100,50,100,0.8)'
;
_ctx
.
fillStyle
=
'rgba(100,50,100,0.8)'
.
toJS
;
}
else
if
(
sample
.
isOutlier
)
{
}
else
if
(
sample
.
isOutlier
)
{
// The sample is an outlier, color it light red.
// The sample is an outlier, color it light red.
_ctx
.
fillStyle
=
'rgba(255,50,50,0.6)'
;
_ctx
.
fillStyle
=
'rgba(255,50,50,0.6)'
.
toJS
;
}
else
{
}
else
{
// A non-outlier sample, color it light blue.
// A non-outlier sample, color it light blue.
_ctx
.
fillStyle
=
'rgba(50,50,255,0.6)'
;
_ctx
.
fillStyle
=
'rgba(50,50,255,0.6)'
.
toJS
;
}
}
_ctx
.
fillRect
(
xOffset
,
0
,
barWidth
-
1
,
_normalized
(
sample
.
magnitude
));
_ctx
.
fillRect
(
xOffset
.
toJS
,
0
.
toJS
,
(
barWidth
-
1
).
toJS
,
_normalized
(
sample
.
magnitude
).
toJS
);
xOffset
+=
barWidth
;
xOffset
+=
barWidth
;
}
}
// Draw a horizontal solid line corresponding to the average.
// Draw a horizontal solid line corresponding to the average.
_ctx
.
lineWidth
=
1
;
_ctx
.
lineWidth
=
1
.
toJS
;
drawLine
(
0
,
_normalized
(
_stats
.
average
),
_screenWidth
,
_normalized
(
_stats
.
average
));
drawLine
(
0
,
_normalized
(
_stats
.
average
),
_screenWidth
,
_normalized
(
_stats
.
average
));
// Draw a horizontal dashed line corresponding to the outlier cut off.
// Draw a horizontal dashed line corresponding to the outlier cut off.
_ctx
.
setLineDash
(<
num
>[
5
,
5
]
);
_ctx
.
setLineDash
(<
JSAny
?>[
5
.
toJS
,
5
.
toJS
].
toJS
);
drawLine
(
0
,
_normalized
(
_stats
.
outlierCutOff
),
_screenWidth
,
_normalized
(
_stats
.
outlierCutOff
));
drawLine
(
0
,
_normalized
(
_stats
.
outlierCutOff
),
_screenWidth
,
_normalized
(
_stats
.
outlierCutOff
));
// Draw a light red band that shows the noise (1 stddev in each direction).
// Draw a light red band that shows the noise (1 stddev in each direction).
_ctx
.
fillStyle
=
'rgba(255,50,50,0.3)'
;
_ctx
.
fillStyle
=
'rgba(255,50,50,0.3)'
.
toJS
;
_ctx
.
fillRect
(
_ctx
.
fillRect
(
0
,
0
.
toJS
,
_normalized
(
_stats
.
average
*
(
1
-
_stats
.
noise
)),
_normalized
(
_stats
.
average
*
(
1
-
_stats
.
noise
))
.
toJS
,
_screenWidth
,
_screenWidth
.
toJS
,
_normalized
(
2
*
_stats
.
average
*
_stats
.
noise
),
_normalized
(
2
*
_stats
.
average
*
_stats
.
noise
)
.
toJS
,
);
);
return
_canvas
;
return
_canvas
;
...
@@ -313,7 +330,7 @@ class LocalBenchmarkServerClient {
...
@@ -313,7 +330,7 @@ class LocalBenchmarkServerClient {
/// Returns [kManualFallback] if local server is not available (uses 404 as a
/// Returns [kManualFallback] if local server is not available (uses 404 as a
/// signal).
/// signal).
Future
<
String
>
requestNextBenchmark
()
async
{
Future
<
String
>
requestNextBenchmark
()
async
{
final
html
.
HttpRequest
request
=
await
_requestXhr
(
final
web
.
XML
HttpRequest
request
=
await
_requestXhr
(
'/next-benchmark'
,
'/next-benchmark'
,
method:
'POST'
,
method:
'POST'
,
mimeType:
'application/json'
,
mimeType:
'application/json'
,
...
@@ -323,13 +340,13 @@ class LocalBenchmarkServerClient {
...
@@ -323,13 +340,13 @@ class LocalBenchmarkServerClient {
// 404 is expected in the following cases:
// 404 is expected in the following cases:
// - The benchmark is ran using plain `flutter run`, which does not provide "next-benchmark" handler.
// - The benchmark is ran using plain `flutter run`, which does not provide "next-benchmark" handler.
// - We ran all benchmarks and the benchmark is telling us there are no more benchmarks to run.
// - We ran all benchmarks and the benchmark is telling us there are no more benchmarks to run.
if
(
request
.
status
==
404
)
{
if
(
request
.
status
.
toDart
!=
200
)
{
isInManualMode
=
true
;
isInManualMode
=
true
;
return
kManualFallback
;
return
kManualFallback
;
}
}
isInManualMode
=
false
;
isInManualMode
=
false
;
return
request
.
responseText
!
;
return
request
.
responseText
.
toDart
;
}
}
void
_checkNotManualMode
()
{
void
_checkNotManualMode
()
{
...
@@ -345,7 +362,7 @@ class LocalBenchmarkServerClient {
...
@@ -345,7 +362,7 @@ class LocalBenchmarkServerClient {
/// DevTools Protocol.
/// DevTools Protocol.
Future
<
void
>
startPerformanceTracing
(
String
benchmarkName
)
async
{
Future
<
void
>
startPerformanceTracing
(
String
benchmarkName
)
async
{
_checkNotManualMode
();
_checkNotManualMode
();
await
html
.
HttpRequest
.
request
(
await
_requestXhr
(
'/start-performance-tracing?label=
$benchmarkName
'
,
'/start-performance-tracing?label=
$benchmarkName
'
,
method:
'POST'
,
method:
'POST'
,
mimeType:
'application/json'
,
mimeType:
'application/json'
,
...
@@ -355,7 +372,7 @@ class LocalBenchmarkServerClient {
...
@@ -355,7 +372,7 @@ class LocalBenchmarkServerClient {
/// Stops the performance tracing session started by [startPerformanceTracing].
/// Stops the performance tracing session started by [startPerformanceTracing].
Future
<
void
>
stopPerformanceTracing
()
async
{
Future
<
void
>
stopPerformanceTracing
()
async
{
_checkNotManualMode
();
_checkNotManualMode
();
await
html
.
HttpRequest
.
request
(
await
_requestXhr
(
'/stop-performance-tracing'
,
'/stop-performance-tracing'
,
method:
'POST'
,
method:
'POST'
,
mimeType:
'application/json'
,
mimeType:
'application/json'
,
...
@@ -366,13 +383,13 @@ class LocalBenchmarkServerClient {
...
@@ -366,13 +383,13 @@ class LocalBenchmarkServerClient {
/// server.
/// server.
Future
<
void
>
sendProfileData
(
Profile
profile
)
async
{
Future
<
void
>
sendProfileData
(
Profile
profile
)
async
{
_checkNotManualMode
();
_checkNotManualMode
();
final
html
.
HttpRequest
request
=
await
html
.
HttpRequest
.
request
(
final
web
.
XMLHttpRequest
request
=
await
_requestXhr
(
'/profile-data'
,
'/profile-data'
,
method:
'POST'
,
method:
'POST'
,
mimeType:
'application/json'
,
mimeType:
'application/json'
,
sendData:
json
.
encode
(
profile
.
toJson
()),
sendData:
json
.
encode
(
profile
.
toJson
()),
);
);
if
(
request
.
status
!=
200
)
{
if
(
request
.
status
.
toDart
!=
200
)
{
throw
Exception
(
throw
Exception
(
'Failed to report profile data to benchmark server. '
'Failed to report profile data to benchmark server. '
'The server responded with status code
${request.status}
.'
'The server responded with status code
${request.status}
.'
...
@@ -385,7 +402,7 @@ class LocalBenchmarkServerClient {
...
@@ -385,7 +402,7 @@ class LocalBenchmarkServerClient {
/// The server will halt the devicelab task and log the error.
/// The server will halt the devicelab task and log the error.
Future
<
void
>
reportError
(
dynamic
error
,
StackTrace
stackTrace
)
async
{
Future
<
void
>
reportError
(
dynamic
error
,
StackTrace
stackTrace
)
async
{
_checkNotManualMode
();
_checkNotManualMode
();
await
html
.
HttpRequest
.
request
(
await
_requestXhr
(
'/on-error'
,
'/on-error'
,
method:
'POST'
,
method:
'POST'
,
mimeType:
'application/json'
,
mimeType:
'application/json'
,
...
@@ -399,7 +416,7 @@ class LocalBenchmarkServerClient {
...
@@ -399,7 +416,7 @@ class LocalBenchmarkServerClient {
/// Reports a message about the demo to the benchmark server.
/// Reports a message about the demo to the benchmark server.
Future
<
void
>
printToConsole
(
String
report
)
async
{
Future
<
void
>
printToConsole
(
String
report
)
async
{
_checkNotManualMode
();
_checkNotManualMode
();
await
html
.
HttpRequest
.
request
(
await
_requestXhr
(
'/print-to-console'
,
'/print-to-console'
,
method:
'POST'
,
method:
'POST'
,
mimeType:
'text/plain'
,
mimeType:
'text/plain'
,
...
@@ -409,7 +426,7 @@ class LocalBenchmarkServerClient {
...
@@ -409,7 +426,7 @@ class LocalBenchmarkServerClient {
/// This is the same as calling [html.HttpRequest.request] but it doesn't
/// This is the same as calling [html.HttpRequest.request] but it doesn't
/// crash on 404, which we use to detect `flutter run`.
/// crash on 404, which we use to detect `flutter run`.
Future
<
html
.
HttpRequest
>
_requestXhr
(
Future
<
web
.
XML
HttpRequest
>
_requestXhr
(
String
url
,
{
String
url
,
{
String
?
method
,
String
?
method
,
bool
?
withCredentials
,
bool
?
withCredentials
,
...
@@ -418,38 +435,40 @@ class LocalBenchmarkServerClient {
...
@@ -418,38 +435,40 @@ class LocalBenchmarkServerClient {
Map
<
String
,
String
>?
requestHeaders
,
Map
<
String
,
String
>?
requestHeaders
,
dynamic
sendData
,
dynamic
sendData
,
})
{
})
{
final
Completer
<
html
.
HttpRequest
>
completer
=
Completer
<
html
.
HttpRequest
>();
final
Completer
<
web
.
XMLHttpRequest
>
completer
=
Completer
<
web
.
XML
HttpRequest
>();
final
html
.
HttpRequest
xhr
=
html
.
HttpRequest
();
final
web
.
XMLHttpRequest
xhr
=
web
.
XML
HttpRequest
();
method
??=
'GET'
;
method
??=
'GET'
;
xhr
.
open
(
method
,
url
,
async:
true
);
xhr
.
open
(
method
.
toJS
,
url
.
toJS
,
true
.
toJS
);
if
(
withCredentials
!=
null
)
{
if
(
withCredentials
!=
null
)
{
xhr
.
withCredentials
=
withCredentials
;
xhr
.
withCredentials
=
withCredentials
.
toJS
;
}
}
if
(
responseType
!=
null
)
{
if
(
responseType
!=
null
)
{
xhr
.
responseType
=
responseType
;
xhr
.
responseType
=
responseType
.
toJS
;
}
}
if
(
mimeType
!=
null
)
{
if
(
mimeType
!=
null
)
{
xhr
.
overrideMimeType
(
mimeType
);
xhr
.
overrideMimeType
(
mimeType
.
toJS
);
}
}
if
(
requestHeaders
!=
null
)
{
if
(
requestHeaders
!=
null
)
{
requestHeaders
.
forEach
((
String
header
,
String
value
)
{
requestHeaders
.
forEach
((
String
header
,
String
value
)
{
xhr
.
setRequestHeader
(
header
,
value
);
xhr
.
setRequestHeader
(
header
.
toJS
,
value
.
toJS
);
});
});
}
}
xhr
.
onLoad
.
listen
((
html
.
ProgressEvent
e
)
{
xhr
.
addEventListener
(
'load'
.
toJS
,
(
web
.
ProgressEvent
e
)
{
completer
.
complete
(
xhr
);
completer
.
complete
(
xhr
);
});
}
.
toJS
);
xhr
.
onError
.
listen
(
completer
.
completeError
);
xhr
.
addEventListener
(
'error'
.
toJS
,
(
JSObject
error
)
{
return
completer
.
completeError
(
error
);
}.
toJS
);
if
(
sendData
!=
null
)
{
if
(
sendData
!=
null
)
{
xhr
.
send
(
sendData
);
xhr
.
send
(
(
sendData
as
Object
?).
jsify
()
);
}
else
{
}
else
{
xhr
.
send
();
xhr
.
send
();
}
}
...
...
dev/benchmarks/macrobenchmarks/pubspec.yaml
View file @
4fea3ef5
...
@@ -18,6 +18,8 @@ dependencies:
...
@@ -18,6 +18,8 @@ dependencies:
# flutter update-packages --force-upgrade
# flutter update-packages --force-upgrade
flutter_gallery_assets
:
1.0.2
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"
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"
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"
characters
:
1.3.0
# THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...
@@ -209,4 +211,4 @@ flutter:
...
@@ -209,4 +211,4 @@ flutter:
fonts
:
fonts
:
-
asset
:
packages/flutter_gallery_assets/fonts/GalleryIcons.ttf
-
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:
...
@@ -21,6 +21,7 @@ dependencies:
shelf_static
:
1.1.2
shelf_static
:
1.1.2
stack_trace
:
1.11.0
stack_trace
:
1.11.0
vm_service
:
11.6.0
vm_service
:
11.6.0
web
:
0.1.2-beta
webkit_inspection_protocol
:
1.2.0
webkit_inspection_protocol
:
1.2.0
_discoveryapis_commons
:
1.0.5
# THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
_discoveryapis_commons
:
1.0.5
# THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...
@@ -69,4 +70,4 @@ dev_dependencies:
...
@@ -69,4 +70,4 @@ dev_dependencies:
watcher
:
1.1.0
# THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
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"
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