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
28d2f010
Unverified
Commit
28d2f010
authored
Jul 05, 2020
by
Tong Mu
Committed by
GitHub
Jul 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Web macrobenchmark: bench_mouse_region_grid_hover now tests hitTestDuration (#60554)
parent
dcbc694b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
17 deletions
+34
-17
bench_mouse_region_grid_hover.dart
...benchmarks/lib/src/web/bench_mouse_region_grid_hover.dart
+17
-2
bench_mouse_region_grid_scroll.dart
...enchmarks/lib/src/web/bench_mouse_region_grid_scroll.dart
+1
-6
recorder.dart
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
+16
-9
No files found.
dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_grid_hover.dart
View file @
28d2f010
...
...
@@ -36,11 +36,17 @@ class _NestedMouseRegion extends StatelessWidget {
///
/// Measures our ability to hit test mouse regions.
class
BenchMouseRegionGridHover
extends
WidgetRecorder
{
BenchMouseRegionGridHover
()
:
super
(
name:
benchmarkName
);
BenchMouseRegionGridHover
()
:
super
(
name:
benchmarkName
)
{
tester
=
_Tester
(
onDataPoint:
handleDataPoint
);
}
static
const
String
benchmarkName
=
'bench_mouse_region_grid_hover'
;
final
_Tester
tester
=
_Tester
();
_Tester
tester
;
void
handleDataPoint
(
Duration
duration
)
{
profile
.
addDataPoint
(
'hitTestDuration'
,
duration
,
reported:
true
);
}
// Use a non-trivial border to force Web to switch painter
Border
_getBorder
(
int
columnIndex
,
int
rowIndex
)
{
...
...
@@ -62,6 +68,7 @@ class BenchMouseRegionGridHover extends WidgetRecorder {
started
=
true
;
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
timeStamp
)
async
{
tester
.
start
();
registerDidStop
(
tester
.
stop
);
});
}
super
.
frameDidDraw
();
...
...
@@ -127,6 +134,10 @@ class _UntilNextFrame {
}
class
_Tester
{
_Tester
({
this
.
onDataPoint
});
final
ValueSetter
<
Duration
>
onDataPoint
;
static
const
Duration
hoverDuration
=
Duration
(
milliseconds:
20
);
bool
_stopped
=
false
;
...
...
@@ -150,7 +161,11 @@ class _Tester {
Future
<
void
>
_hoverTo
(
Offset
location
,
Duration
duration
)
async
{
currentTime
+=
duration
;
final
Stopwatch
stopwatch
=
Stopwatch
()..
start
();
await
gesture
.
moveTo
(
location
,
timeStamp:
currentTime
);
stopwatch
.
stop
();
if
(
onDataPoint
!=
null
)
onDataPoint
(
stopwatch
.
elapsed
);
await
_UntilNextFrame
.
wait
();
}
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/bench_mouse_region_grid_scroll.dart
View file @
28d2f010
...
...
@@ -43,12 +43,7 @@ class BenchMouseRegionGridScroll extends WidgetRecorder {
started
=
true
;
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
timeStamp
)
async
{
tester
.
start
();
final
VoidCallback
localDidStop
=
didStop
;
didStop
=
()
{
if
(
localDidStop
!=
null
)
localDidStop
();
tester
.
stop
();
};
registerDidStop
(
tester
.
stop
);
});
}
super
.
frameDidDraw
();
...
...
dev/benchmarks/macrobenchmarks/lib/src/web/recorder.dart
View file @
28d2f010
...
...
@@ -345,8 +345,11 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
/// pumping frames automatically.
Widget
createWidget
();
final
List
<
VoidCallback
>
_didStopCallbacks
=
<
VoidCallback
>[];
@override
VoidCallback
didStop
;
void
registerDidStop
(
VoidCallback
fn
)
{
_didStopCallbacks
.
add
(
fn
);
}
@override
Profile
profile
;
...
...
@@ -373,7 +376,8 @@ abstract class WidgetRecorder extends Recorder implements FrameRecorder {
if
(
shouldContinue
())
{
window
.
scheduleFrame
();
}
else
{
didStop
();
for
(
final
VoidCallback
fn
in
_didStopCallbacks
)
fn
();
_runCompleter
.
complete
();
}
}
...
...
@@ -437,8 +441,11 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
/// consider using [WidgetRecorder].
Widget
createWidget
();
final
List
<
VoidCallback
>
_didStopCallbacks
=
<
VoidCallback
>[];
@override
VoidCallback
didStop
;
void
registerDidStop
(
VoidCallback
fn
)
{
_didStopCallbacks
.
add
(
fn
);
}
@override
Profile
profile
;
...
...
@@ -484,7 +491,8 @@ abstract class WidgetBuildRecorder extends Recorder implements FrameRecorder {
showWidget
=
!
showWidget
;
_hostState
.
_setStateTrampoline
();
}
else
{
didStop
();
for
(
final
VoidCallback
fn
in
_didStopCallbacks
)
fn
();
_runCompleter
.
complete
();
}
}
...
...
@@ -942,9 +950,8 @@ String _ratioToPercent(double value) {
/// Implemented by recorders that use [_RecordingWidgetsBinding] to receive
/// frame life-cycle calls.
abstract
class
FrameRecorder
{
/// Called by the recorder when it stops recording and doesn't need to collect
/// any more data.
set
didStop
(
VoidCallback
cb
);
/// Add a callback that will be called by the recorder when it stops recording.
void
registerDidStop
(
VoidCallback
cb
);
/// Called just before calling [SchedulerBinding.handleDrawFrame].
void
frameWillDraw
();
...
...
@@ -998,9 +1005,9 @@ class _RecordingWidgetsBinding extends BindingBase
}
final
FlutterExceptionHandler
originalOnError
=
FlutterError
.
onError
;
recorder
.
didStop
=
()
{
recorder
.
registerDidStop
(
()
{
_benchmarkStopped
=
true
;
};
}
)
;
// Fail hard and fast on errors. Benchmarks should not have any errors.
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
...
...
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