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
e6aa6ce2
Unverified
Commit
e6aa6ce2
authored
Jun 07, 2021
by
Abhishek Ghaskata
Committed by
GitHub
Jun 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate platform channels benchmarks (#84066)
parent
bcc8f083
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
main.dart
dev/benchmarks/platform_channels_benchmarks/lib/main.dart
+13
-13
pubspec.yaml
dev/benchmarks/platform_channels_benchmarks/pubspec.yaml
+1
-1
No files found.
dev/benchmarks/platform_channels_benchmarks/lib/main.dart
View file @
e6aa6ce2
...
@@ -12,8 +12,8 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -12,8 +12,8 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:microbenchmarks/common.dart'
;
import
'package:microbenchmarks/common.dart'
;
List
<
Object
>
_makeTestBuffer
(
int
size
)
{
List
<
Object
?
>
_makeTestBuffer
(
int
size
)
{
final
List
<
Object
>
answer
=
<
Object
>[];
final
List
<
Object
?>
answer
=
<
Object
?
>[];
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
switch
(
i
%
9
)
{
switch
(
i
%
9
)
{
case
0
:
case
0
:
...
@@ -49,7 +49,7 @@ List<Object> _makeTestBuffer(int size) {
...
@@ -49,7 +49,7 @@ List<Object> _makeTestBuffer(int size) {
}
}
Future
<
double
>
_runBasicStandardSmall
(
Future
<
double
>
_runBasicStandardSmall
(
BasicMessageChannel
<
Object
>
basicStandard
,
int
count
)
async
{
BasicMessageChannel
<
Object
?
>
basicStandard
,
int
count
)
async
{
final
Stopwatch
watch
=
Stopwatch
();
final
Stopwatch
watch
=
Stopwatch
();
watch
.
start
();
watch
.
start
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
...
@@ -59,14 +59,14 @@ Future<double> _runBasicStandardSmall(
...
@@ -59,14 +59,14 @@ Future<double> _runBasicStandardSmall(
return
watch
.
elapsedMicroseconds
/
count
;
return
watch
.
elapsedMicroseconds
/
count
;
}
}
Future
<
double
>
_runBasicStandardLarge
(
BasicMessageChannel
<
Object
>
basicStandard
,
Future
<
double
>
_runBasicStandardLarge
(
BasicMessageChannel
<
Object
?
>
basicStandard
,
List
<
Object
>
largeBuffer
,
int
count
)
async
{
List
<
Object
?
>
largeBuffer
,
int
count
)
async
{
int
size
=
0
;
int
size
=
0
;
final
Stopwatch
watch
=
Stopwatch
();
final
Stopwatch
watch
=
Stopwatch
();
watch
.
start
();
watch
.
start
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
final
List
<
Object
>
result
=
final
List
<
Object
?>?
result
=
await
basicStandard
.
send
(
largeBuffer
)
as
List
<
Object
>
;
await
basicStandard
.
send
(
largeBuffer
)
as
List
<
Object
?>?
;
// This check should be tiny compared to the actual channel send/receive.
// This check should be tiny compared to the actual channel send/receive.
size
+=
(
result
==
null
)
?
0
:
result
.
length
;
size
+=
(
result
==
null
)
?
0
:
result
.
length
;
}
}
...
@@ -87,7 +87,7 @@ Future<double> _runBasicBinary(BasicMessageChannel<ByteData> basicBinary,
...
@@ -87,7 +87,7 @@ Future<double> _runBasicBinary(BasicMessageChannel<ByteData> basicBinary,
final
Stopwatch
watch
=
Stopwatch
();
final
Stopwatch
watch
=
Stopwatch
();
watch
.
start
();
watch
.
start
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
final
ByteData
result
=
await
basicBinary
.
send
(
buffer
);
final
ByteData
?
result
=
await
basicBinary
.
send
(
buffer
);
// This check should be tiny compared to the actual channel send/receive.
// This check should be tiny compared to the actual channel send/receive.
size
+=
(
result
==
null
)
?
0
:
result
.
lengthInBytes
;
size
+=
(
result
==
null
)
?
0
:
result
.
lengthInBytes
;
}
}
...
@@ -108,11 +108,11 @@ Future<void> _runTests() async {
...
@@ -108,11 +108,11 @@ Future<void> _runTests() async {
);
);
}
}
const
BasicMessageChannel
<
Object
>
resetChannel
=
BasicMessageChannel
<
Object
>(
const
BasicMessageChannel
<
Object
?>
resetChannel
=
BasicMessageChannel
<
Object
?
>(
'dev.flutter.echo.reset'
,
'dev.flutter.echo.reset'
,
StandardMessageCodec
(),
StandardMessageCodec
(),
);
);
const
BasicMessageChannel
<
Object
>
basicStandard
=
BasicMessageChannel
<
Object
>(
const
BasicMessageChannel
<
Object
?>
basicStandard
=
BasicMessageChannel
<
Object
?
>(
'dev.flutter.echo.basic.standard'
,
'dev.flutter.echo.basic.standard'
,
StandardMessageCodec
(),
StandardMessageCodec
(),
);
);
...
@@ -125,9 +125,9 @@ Future<void> _runTests() async {
...
@@ -125,9 +125,9 @@ Future<void> _runTests() async {
/// WARNING: Don't change the following line of code, it will invalidate
/// WARNING: Don't change the following line of code, it will invalidate
/// `Large` tests. Instead make a different test. The size of largeBuffer
/// `Large` tests. Instead make a different test. The size of largeBuffer
/// serialized is 14214 bytes.
/// serialized is 14214 bytes.
final
List
<
Object
>
largeBuffer
=
_makeTestBuffer
(
1000
);
final
List
<
Object
?
>
largeBuffer
=
_makeTestBuffer
(
1000
);
final
ByteData
largeBufferBytes
=
final
ByteData
largeBufferBytes
=
const
StandardMessageCodec
().
encodeMessage
(
largeBuffer
);
const
StandardMessageCodec
().
encodeMessage
(
largeBuffer
)
!
;
final
ByteData
oneMB
=
ByteData
(
1024
*
1024
);
final
ByteData
oneMB
=
ByteData
(
1024
*
1024
);
const
int
numMessages
=
2500
;
const
int
numMessages
=
2500
;
...
@@ -170,7 +170,7 @@ Future<void> _runTests() async {
...
@@ -170,7 +170,7 @@ Future<void> _runTests() async {
}
}
class
_BenchmarkWidget
extends
StatefulWidget
{
class
_BenchmarkWidget
extends
StatefulWidget
{
const
_BenchmarkWidget
(
this
.
tests
,
{
Key
key
})
:
super
(
key:
key
);
const
_BenchmarkWidget
(
this
.
tests
,
{
Key
?
key
})
:
super
(
key:
key
);
final
Future
<
void
>
Function
()
tests
;
final
Future
<
void
>
Function
()
tests
;
...
...
dev/benchmarks/platform_channels_benchmarks/pubspec.yaml
View file @
e6aa6ce2
...
@@ -5,7 +5,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
...
@@ -5,7 +5,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version
:
1.0.0+1
version
:
1.0.0+1
environment
:
environment
:
sdk
:
"
>=2.
9
.0
<3.0.0"
sdk
:
"
>=2.
12
.0
<3.0.0"
dependencies
:
dependencies
:
flutter
:
flutter
:
...
...
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