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
8694e19a
Unverified
Commit
8694e19a
authored
May 07, 2021
by
gaaclarke
Committed by
GitHub
May 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added binary platform channels test (#81874)
parent
4b65c058
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
28 deletions
+98
-28
MainActivity.kt
.../com/example/platform_channels_benchmarks/MainActivity.kt
+8
-0
AppDelegate.swift
...platform_channels_benchmarks/ios/Runner/AppDelegate.swift
+6
-0
main.dart
dev/benchmarks/platform_channels_benchmarks/lib/main.dart
+82
-26
prod_builders.json
dev/prod_builders.json
+2
-2
No files found.
dev/benchmarks/platform_channels_benchmarks/android/app/src/main/kotlin/com/example/platform_channels_benchmarks/MainActivity.kt
View file @
8694e19a
...
@@ -7,13 +7,21 @@ package com.example.platform_channels_benchmarks
...
@@ -7,13 +7,21 @@ package com.example.platform_channels_benchmarks
import
io.flutter.embedding.android.FlutterActivity
import
io.flutter.embedding.android.FlutterActivity
import
io.flutter.embedding.engine.FlutterEngine
import
io.flutter.embedding.engine.FlutterEngine
import
io.flutter.plugin.common.BasicMessageChannel
import
io.flutter.plugin.common.BasicMessageChannel
import
io.flutter.plugin.common.BinaryCodec
import
io.flutter.plugin.common.StandardMessageCodec
import
io.flutter.plugin.common.StandardMessageCodec
import
java.nio.ByteBuffer
class
MainActivity
:
FlutterActivity
()
{
class
MainActivity
:
FlutterActivity
()
{
override
fun
configureFlutterEngine
(
flutterEngine
:
FlutterEngine
)
{
override
fun
configureFlutterEngine
(
flutterEngine
:
FlutterEngine
)
{
val
basicStandard
=
BasicMessageChannel
(
flutterEngine
.
dartExecutor
,
"dev.flutter.echo.basic.standard"
,
StandardMessageCodec
.
INSTANCE
)
val
basicStandard
=
BasicMessageChannel
(
flutterEngine
.
dartExecutor
,
"dev.flutter.echo.basic.standard"
,
StandardMessageCodec
.
INSTANCE
)
basicStandard
.
setMessageHandler
{
message
,
reply
->
reply
.
reply
(
message
)
}
basicStandard
.
setMessageHandler
{
message
,
reply
->
reply
.
reply
(
message
)
}
val
basicBinary
=
BasicMessageChannel
(
flutterEngine
.
dartExecutor
,
"dev.flutter.echo.basic.binary"
,
BinaryCodec
.
INSTANCE
)
basicBinary
.
setMessageHandler
{
message
,
reply
->
run
{
val
result
=
ByteBuffer
.
allocateDirect
(
message
!!
.
capacity
())
result
.
put
(
message
)
reply
.
reply
(
result
)
}
}
super
.
configureFlutterEngine
(
flutterEngine
)
super
.
configureFlutterEngine
(
flutterEngine
)
}
}
}
}
dev/benchmarks/platform_channels_benchmarks/ios/Runner/AppDelegate.swift
View file @
8694e19a
...
@@ -20,6 +20,12 @@ import UIKit
...
@@ -20,6 +20,12 @@ import UIKit
basicStandard
.
setMessageHandler
{
(
input
,
reply
)
in
basicStandard
.
setMessageHandler
{
(
input
,
reply
)
in
reply
(
input
)
reply
(
input
)
}
}
let
basicBinary
=
FlutterBasicMessageChannel
(
name
:
"dev.flutter.echo.basic.binary"
,
binaryMessenger
:
registrar
.
messenger
(),
codec
:
FlutterBinaryCodec
())
basicBinary
.
setMessageHandler
{
(
input
,
reply
)
in
reply
(
input
)
}
return
super
.
application
(
application
,
didFinishLaunchingWithOptions
:
launchOptions
)
return
super
.
application
(
application
,
didFinishLaunchingWithOptions
:
launchOptions
)
}
}
...
...
dev/benchmarks/platform_channels_benchmarks/lib/main.dart
View file @
8694e19a
...
@@ -48,60 +48,116 @@ List<Object> _makeTestBuffer(int size) {
...
@@ -48,60 +48,116 @@ List<Object> _makeTestBuffer(int size) {
return
answer
;
return
answer
;
}
}
Future
<
void
>
_runTests
()
async
{
Future
<
double
>
_runBasicStandardSmall
(
if
(
kDebugMode
)
{
BasicMessageChannel
<
Object
>
basicStandard
,
int
count
)
async
{
throw
Exception
(
final
Stopwatch
watch
=
Stopwatch
();
"Must be run in profile mode! Use 'flutter run --profile'."
);
watch
.
start
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
await
basicStandard
.
send
(
1234
);
}
}
const
int
numMessages
=
2500
;
watch
.
stop
();
return
watch
.
elapsedMicroseconds
/
count
;
}
const
BasicMessageChannel
<
Object
>
channel
=
BasicMessageChannel
<
Object
>(
Future
<
double
>
_runBasicStandardLarge
(
BasicMessageChannel
<
Object
>
basicStandard
,
'dev.flutter.echo.basic.standard'
,
List
<
Object
>
largeBuffer
,
int
count
)
async
{
StandardMessageCodec
(),
int
size
=
0
;
);
final
Stopwatch
watch
=
Stopwatch
();
final
Stopwatch
watch
=
Stopwatch
();
watch
.
start
();
watch
.
start
();
for
(
int
i
=
0
;
i
<
numMessages
;
++
i
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
await
channel
.
send
(
1234
);
final
List
<
Object
>
result
=
await
basicStandard
.
send
(
largeBuffer
)
as
List
<
Object
>;
// This check should be tiny compared to the actual channel send/receive.
size
+=
(
result
==
null
)
?
0
:
result
.
length
;
}
}
watch
.
stop
();
watch
.
stop
();
final
double
smallPayloadTime
=
watch
.
elapsedMicroseconds
/
numMessages
;
watch
.
reset
();
if
(
size
!=
largeBuffer
.
length
*
count
)
{
/// WARNING: Don't change the following line of code, it will invalidate
throw
Exception
(
/// `Large` tests. Instead make a different test. The size of largeBuffer
'There is an error with the echo channel, the results don
\'
t add up:
$size
'
,
/// serialized is 14214 bytes.
);
final
List
<
Object
>
largeBuffer
=
_makeTestBuffer
(
1000
);
}
return
watch
.
elapsedMicroseconds
/
count
;
}
Future
<
double
>
_runBasicBinary
(
BasicMessageChannel
<
ByteData
>
basicBinary
,
ByteData
buffer
,
int
count
)
async
{
int
size
=
0
;
int
size
=
0
;
final
Stopwatch
watch
=
Stopwatch
();
watch
.
start
();
watch
.
start
();
for
(
int
i
=
0
;
i
<
numMessages
;
++
i
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
final
List
<
Object
>
result
=
await
channel
.
send
(
largeBuffer
)
as
List
<
Object
>
;
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
.
length
;
size
+=
(
result
==
null
)
?
0
:
result
.
length
InBytes
;
}
}
watch
.
stop
();
watch
.
stop
();
final
double
largePayloadTime
=
watch
.
elapsedMicroseconds
/
numMessages
;
if
(
size
!=
buffer
.
lengthInBytes
*
count
)
{
throw
Exception
(
'There is an error with the echo channel, the results don
\'
t add up:
$size
'
,
);
}
return
watch
.
elapsedMicroseconds
/
count
;
}
if
(
size
!=
largeBuffer
.
length
*
numMessages
)
{
Future
<
void
>
_runTests
()
async
{
if
(
kDebugMode
)
{
throw
Exception
(
throw
Exception
(
'There is an error with the echo channel, the results don
\'
t add up:
$size
'
);
"Must be run in profile mode! Use 'flutter run --profile'."
,
);
}
}
const
BasicMessageChannel
<
Object
>
basicStandard
=
BasicMessageChannel
<
Object
>(
'dev.flutter.echo.basic.standard'
,
StandardMessageCodec
(),
);
const
BasicMessageChannel
<
ByteData
>
basicBinary
=
BasicMessageChannel
<
ByteData
>(
'dev.flutter.echo.basic.binary'
,
BinaryCodec
(),
);
/// WARNING: Don't change the following line of code, it will invalidate
/// `Large` tests. Instead make a different test. The size of largeBuffer
/// serialized is 14214 bytes.
final
List
<
Object
>
largeBuffer
=
_makeTestBuffer
(
1000
);
final
ByteData
largeBufferBytes
=
const
StandardMessageCodec
().
encodeMessage
(
largeBuffer
);
final
ByteData
oneMB
=
ByteData
(
1024
*
1024
);
const
int
numMessages
=
2500
;
final
BenchmarkResultPrinter
printer
=
BenchmarkResultPrinter
();
final
BenchmarkResultPrinter
printer
=
BenchmarkResultPrinter
();
await
_runBasicStandardSmall
(
basicStandard
,
1
);
// Warmup.
printer
.
addResult
(
printer
.
addResult
(
description:
'BasicMessageChannel/StandardMessageCodec/Flutter->Host/Small'
,
description:
'BasicMessageChannel/StandardMessageCodec/Flutter->Host/Small'
,
value:
smallPayloadTime
,
value:
await
_runBasicStandardSmall
(
basicStandard
,
numMessages
)
,
unit:
'µs'
,
unit:
'µs'
,
name:
'platform_channel_basic_standard_2host_small'
,
name:
'platform_channel_basic_standard_2host_small'
,
);
);
await
_runBasicStandardLarge
(
basicStandard
,
largeBuffer
,
1
);
// Warmup.
printer
.
addResult
(
printer
.
addResult
(
description:
'BasicMessageChannel/StandardMessageCodec/Flutter->Host/Large'
,
description:
'BasicMessageChannel/StandardMessageCodec/Flutter->Host/Large'
,
value:
largePayloadTime
,
value:
await
_runBasicStandardLarge
(
basicStandard
,
largeBuffer
,
numMessages
),
unit:
'µs'
,
unit:
'µs'
,
name:
'platform_channel_basic_standard_2host_large'
,
name:
'platform_channel_basic_standard_2host_large'
,
);
);
await
_runBasicBinary
(
basicBinary
,
largeBufferBytes
,
1
);
// Warmup.
printer
.
addResult
(
description:
'BasicMessageChannel/BinaryCodec/Flutter->Host/Large'
,
value:
await
_runBasicBinary
(
basicBinary
,
largeBufferBytes
,
numMessages
),
unit:
'µs'
,
name:
'platform_channel_basic_binary_2host_large'
,
);
await
_runBasicBinary
(
basicBinary
,
oneMB
,
1
);
// Warmup.
printer
.
addResult
(
description:
'BasicMessageChannel/BinaryCodec/Flutter->Host/1MB'
,
value:
await
_runBasicBinary
(
basicBinary
,
oneMB
,
numMessages
),
unit:
'µs'
,
name:
'platform_channel_basic_binary_2host_1MB'
,
);
printer
.
printToStdout
();
printer
.
printToStdout
();
}
}
...
...
dev/prod_builders.json
View file @
8694e19a
...
@@ -373,7 +373,7 @@
...
@@ -373,7 +373,7 @@
"flaky"
:
false
"flaky"
:
false
},
},
{
{
"name"
:
"Linux platform
channels
benchmarks"
,
"name"
:
"Linux platform
_channels_
benchmarks"
,
"repo"
:
"flutter"
,
"repo"
:
"flutter"
,
"task_name"
:
"linux_platform_channels_benchmarks"
,
"task_name"
:
"linux_platform_channels_benchmarks"
,
"flaky"
:
true
"flaky"
:
true
...
@@ -1159,7 +1159,7 @@
...
@@ -1159,7 +1159,7 @@
"flaky"
:
false
"flaky"
:
false
},
},
{
{
"name"
:
"Mac_ios platform
channels
benchmarks"
,
"name"
:
"Mac_ios platform
_channels_
benchmarks"
,
"repo"
:
"flutter"
,
"repo"
:
"flutter"
,
"task_name"
:
"mac_ios_platform_channels_benchmarks"
,
"task_name"
:
"mac_ios_platform_channels_benchmarks"
,
"flaky"
:
true
"flaky"
:
true
...
...
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