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
d25a5c37
Unverified
Commit
d25a5c37
authored
Jun 02, 2021
by
Abhishek Ghaskata
Committed by
GitHub
Jun 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate microbrenchmarks to null safety (#83619)
parent
15317b9e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
24 additions
and
24 deletions
+24
-24
common.dart
dev/benchmarks/microbenchmarks/lib/common.dart
+1
-3
all_elements_bench.dart
...ks/microbenchmarks/lib/foundation/all_elements_bench.dart
+5
-5
curves_bench.dart
...benchmarks/microbenchmarks/lib/geometry/curves_bench.dart
+1
-1
button_matrix_app.dart
.../microbenchmarks/lib/gestures/apps/button_matrix_app.dart
+1
-1
velocity_tracker_bench.dart
.../microbenchmarks/lib/gestures/velocity_tracker_bench.dart
+1
-1
sync_star_semantics_bench.dart
...crobenchmarks/lib/language/sync_star_semantics_bench.dart
+8
-6
animation_bench.dart
...enchmarks/microbenchmarks/lib/stocks/animation_bench.dart
+2
-2
layout_bench.dart
dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart
+4
-4
pubspec.yaml
dev/benchmarks/microbenchmarks/pubspec.yaml
+1
-1
No files found.
dev/benchmarks/microbenchmarks/lib/common.dart
View file @
d25a5c37
...
...
@@ -4,8 +4,6 @@
import
'dart:convert'
show
json
;
import
'package:meta/meta.dart'
;
/// This class knows how to format benchmark results for machine and human
/// consumption.
///
...
...
@@ -31,7 +29,7 @@ class BenchmarkResultPrinter {
/// result value. [unit] is the unit of measurement, such as "ms", "km", "h".
/// [name] is a computer-readable name of the result used as a key in the JSON
/// serialization of the results.
void
addResult
({
@required
String
description
,
@required
double
value
,
@required
String
unit
,
@
required
String
name
})
{
void
addResult
({
required
String
description
,
required
double
value
,
required
String
unit
,
required
String
name
})
{
_results
.
add
(
_BenchmarkResult
(
description
,
value
,
unit
,
name
));
}
...
...
dev/benchmarks/microbenchmarks/lib/foundation/all_elements_bench.dart
View file @
d25a5c37
...
...
@@ -44,24 +44,24 @@ Future<void> main() async {
// Wait for frame rendering to stabilize.
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
await
SchedulerBinding
.
instance
.
endOfFrame
;
await
SchedulerBinding
.
instance
?
.
endOfFrame
;
}
final
Stopwatch
watch
=
Stopwatch
();
print
(
'flutter_test allElements benchmark... (
${WidgetsBinding.instance.renderViewElement}
)'
);
print
(
'flutter_test allElements benchmark... (
${WidgetsBinding.instance
?
.renderViewElement}
)'
);
// Make sure we get enough elements to process for consistent benchmark runs
int
elementCount
=
collectAllElementsFrom
(
WidgetsBinding
.
instance
.
renderViewElement
,
skipOffstage:
false
).
length
;
int
elementCount
=
collectAllElementsFrom
(
WidgetsBinding
.
instance
!.
renderViewElement
!
,
skipOffstage:
false
).
length
;
while
(
elementCount
<
2458
)
{
await
Future
<
void
>.
delayed
(
Duration
.
zero
);
elementCount
=
collectAllElementsFrom
(
WidgetsBinding
.
instance
.
renderViewElement
,
skipOffstage:
false
).
length
;
elementCount
=
collectAllElementsFrom
(
WidgetsBinding
.
instance
!.
renderViewElement
!
,
skipOffstage:
false
).
length
;
}
print
(
'element count:
$elementCount
'
);
watch
.
start
();
for
(
int
i
=
0
;
i
<
_kNumIters
;
i
+=
1
)
{
final
List
<
Element
>
allElements
=
collectAllElementsFrom
(
WidgetsBinding
.
instance
.
renderViewElement
,
WidgetsBinding
.
instance
!.
renderViewElement
!
,
skipOffstage:
false
,
).
toList
();
allElements
.
clear
();
...
...
dev/benchmarks/microbenchmarks/lib/geometry/curves_bench.dart
View file @
d25a5c37
...
...
@@ -9,7 +9,7 @@ import '../common.dart';
const
int
_kNumIters
=
10000
;
void
_testCurve
(
Curve
curve
,
{
String
name
,
String
description
,
BenchmarkResultPrinter
printer
})
{
void
_testCurve
(
Curve
curve
,
{
required
String
name
,
required
String
description
,
required
BenchmarkResultPrinter
printer
})
{
final
Stopwatch
watch
=
Stopwatch
();
print
(
'
$description
benchmark...'
);
watch
.
start
();
...
...
dev/benchmarks/microbenchmarks/lib/gestures/apps/button_matrix_app.dart
View file @
d25a5c37
...
...
@@ -5,7 +5,7 @@
import
'package:flutter/material.dart'
;
class
ButtonMatrixApp
extends
StatefulWidget
{
const
ButtonMatrixApp
({
Key
key
})
:
super
(
key:
key
);
const
ButtonMatrixApp
({
Key
?
key
})
:
super
(
key:
key
);
@override
ButtonMatrixAppState
createState
()
=>
ButtonMatrixAppState
();
...
...
dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart
View file @
d25a5c37
...
...
@@ -10,7 +10,7 @@ import 'data/velocity_tracker_data.dart';
const
int
_kNumIters
=
10000
;
class
TrackerBenchmark
{
TrackerBenchmark
({
this
.
name
,
this
.
tracker
});
TrackerBenchmark
({
required
this
.
name
,
required
this
.
tracker
});
final
VelocityTracker
tracker
;
final
String
name
;
...
...
dev/benchmarks/microbenchmarks/lib/language/sync_star_semantics_bench.dart
View file @
d25a5c37
...
...
@@ -80,7 +80,7 @@ String consumeSpan(Iterable<InlineSpanSemanticsInformation> items) {
Iterable
<
InlineSpanSemanticsInformation
>
combineSemanticsInfoSyncStar
(
List
<
InlineSpanSemanticsInformation
>
inputs
)
sync
*
{
String
workingText
=
''
;
String
workingLabel
;
String
?
workingLabel
;
for
(
final
InlineSpanSemanticsInformation
info
in
inputs
)
{
if
(
info
.
requiresOwnNode
)
{
if
(
workingText
!=
null
)
{
...
...
@@ -92,8 +92,9 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoSyncStar(List<Inlin
}
else
{
workingText
+=
info
.
text
;
workingLabel
??=
''
;
if
(
info
.
semanticsLabel
!=
null
)
{
workingLabel
+=
info
.
semanticsLabel
;
final
String
?
infoSemanticsLabel
=
info
.
semanticsLabel
;
if
(
infoSemanticsLabel
!=
null
)
{
workingLabel
+=
infoSemanticsLabel
;
}
else
{
workingLabel
+=
info
.
text
;
}
...
...
@@ -108,7 +109,7 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoSyncStar(List<Inlin
Iterable
<
InlineSpanSemanticsInformation
>
combineSemanticsInfoList
(
List
<
InlineSpanSemanticsInformation
>
inputs
)
{
String
workingText
=
''
;
String
workingLabel
;
String
?
workingLabel
;
final
List
<
InlineSpanSemanticsInformation
>
result
=
<
InlineSpanSemanticsInformation
>[];
for
(
final
InlineSpanSemanticsInformation
info
in
inputs
)
{
if
(
info
.
requiresOwnNode
)
{
...
...
@@ -121,8 +122,9 @@ Iterable<InlineSpanSemanticsInformation> combineSemanticsInfoList(List<InlineSpa
}
else
{
workingText
+=
info
.
text
;
workingLabel
??=
''
;
if
(
info
.
semanticsLabel
!=
null
)
{
workingLabel
+=
info
.
semanticsLabel
;
final
String
?
infoSemanticsLabel
=
info
.
semanticsLabel
;
if
(
infoSemanticsLabel
!=
null
)
{
workingLabel
+=
infoSemanticsLabel
;
}
else
{
workingLabel
+=
info
.
text
;
}
...
...
dev/benchmarks/microbenchmarks/lib/stocks/animation_bench.dart
View file @
d25a5c37
...
...
@@ -17,7 +17,7 @@ class BenchmarkingBinding extends LiveTestWidgetsFlutterBinding {
final
Stopwatch
stopwatch
;
@override
void
handleBeginFrame
(
Duration
rawTimeStamp
)
{
void
handleBeginFrame
(
Duration
?
rawTimeStamp
)
{
stopwatch
.
start
();
super
.
handleBeginFrame
(
rawTimeStamp
);
}
...
...
@@ -68,7 +68,7 @@ Future<void> main() async {
// Time how long each frame takes
cpuWatch
.
reset
();
while
(
SchedulerBinding
.
instance
.
hasScheduledFrame
)
{
while
(
SchedulerBinding
.
instance
!
.
hasScheduledFrame
)
{
await
tester
.
pump
();
totalSubsequentFramesIterationCount
+=
1
;
}
...
...
dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart
View file @
d25a5c37
...
...
@@ -33,18 +33,18 @@ Future<void> main() async {
final
TestViewConfiguration
big
=
TestViewConfiguration
(
size:
const
Size
(
360.0
,
640.0
),
window:
RendererBinding
.
instance
.
window
,
window:
RendererBinding
.
instance
?
.
window
,
);
final
TestViewConfiguration
small
=
TestViewConfiguration
(
size:
const
Size
(
355.0
,
635.0
),
window:
RendererBinding
.
instance
.
window
,
window:
RendererBinding
.
instance
?
.
window
,
);
final
RenderView
renderView
=
WidgetsBinding
.
instance
.
renderView
;
final
RenderView
?
renderView
=
WidgetsBinding
.
instance
?
.
renderView
;
binding
.
framePolicy
=
LiveTestWidgetsFlutterBindingFramePolicy
.
benchmark
;
watch
.
start
();
while
(
watch
.
elapsed
<
kBenchmarkTime
)
{
renderView
.
configuration
=
iterations
.
isEven
?
big
:
small
;
renderView
?
.
configuration
=
iterations
.
isEven
?
big
:
small
;
await
tester
.
pumpBenchmark
(
Duration
(
milliseconds:
iterations
*
16
));
iterations
+=
1
;
}
...
...
dev/benchmarks/microbenchmarks/pubspec.yaml
View file @
d25a5c37
...
...
@@ -2,7 +2,7 @@ name: microbenchmarks
description
:
Small benchmarks for very specific parts of the Flutter framework.
environment
:
sdk
:
"
>=2.
0.0-dev.68
.0
<3.0.0"
sdk
:
"
>=2.
12
.0
<3.0.0"
dependencies
:
meta
:
1.4.0
...
...
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