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
ade6e1f9
Unverified
Commit
ade6e1f9
authored
May 24, 2021
by
gaaclarke
Committed by
GitHub
May 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the android platform channel benchmarks comparable to iOS (#83110)
parent
c500a062
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
4 deletions
+26
-4
MainActivity.kt
.../com/example/platform_channels_benchmarks/MainActivity.kt
+13
-4
AppDelegate.swift
...platform_channels_benchmarks/ios/Runner/AppDelegate.swift
+5
-0
main.dart
dev/benchmarks/platform_channels_benchmarks/lib/main.dart
+8
-0
No files found.
dev/benchmarks/platform_channels_benchmarks/android/app/src/main/kotlin/com/example/platform_channels_benchmarks/MainActivity.kt
View file @
ade6e1f9
...
...
@@ -12,15 +12,24 @@ import io.flutter.plugin.common.StandardMessageCodec
import
java.nio.ByteBuffer
class
MainActivity
:
FlutterActivity
()
{
// We allow for the caching of a response in the binary channel case since
// the reply requires a direct buffer, but the input is not a direct buffer.
// We can't directly send the input back to the reply currently.
private
var
byteBufferCache
:
ByteBuffer
?
=
null
override
fun
configureFlutterEngine
(
flutterEngine
:
FlutterEngine
)
{
val
reset
=
BasicMessageChannel
(
flutterEngine
.
dartExecutor
,
"dev.flutter.echo.reset"
,
StandardMessageCodec
.
INSTANCE
)
reset
.
setMessageHandler
{
message
,
reply
->
run
{
byteBufferCache
=
null
}
}
val
basicStandard
=
BasicMessageChannel
(
flutterEngine
.
dartExecutor
,
"dev.flutter.echo.basic.standard"
,
StandardMessageCodec
.
INSTANCE
)
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
)
if
(
byteBufferCache
==
null
)
{
byteBufferCache
=
ByteBuffer
.
allocateDirect
(
message
!!
.
capacity
())
byteBufferCache
!!
.
put
(
message
)
}
reply
.
reply
(
byteBufferCache
)
}
}
super
.
configureFlutterEngine
(
flutterEngine
)
}
...
...
dev/benchmarks/platform_channels_benchmarks/ios/Runner/AppDelegate.swift
View file @
ade6e1f9
...
...
@@ -14,6 +14,11 @@ import UIKit
GeneratedPluginRegistrant
.
register
(
with
:
self
)
let
registrar
=
self
.
registrar
(
forPlugin
:
"Echo"
)
!
let
reset
=
FlutterBasicMessageChannel
(
name
:
"dev.flutter.echo.reset"
,
binaryMessenger
:
registrar
.
messenger
())
reset
.
setMessageHandler
{
(
input
,
reply
)
in
// noop
}
let
basicStandard
=
FlutterBasicMessageChannel
(
name
:
"dev.flutter.echo.basic.standard"
,
binaryMessenger
:
registrar
.
messenger
(),
codec
:
FlutterStandardMessageCodec
.
sharedInstance
())
...
...
dev/benchmarks/platform_channels_benchmarks/lib/main.dart
View file @
ade6e1f9
...
...
@@ -108,6 +108,10 @@ Future<void> _runTests() async {
);
}
const
BasicMessageChannel
<
Object
>
resetChannel
=
BasicMessageChannel
<
Object
>(
'dev.flutter.echo.reset'
,
StandardMessageCodec
(),
);
const
BasicMessageChannel
<
Object
>
basicStandard
=
BasicMessageChannel
<
Object
>(
'dev.flutter.echo.basic.standard'
,
StandardMessageCodec
(),
...
...
@@ -129,6 +133,7 @@ Future<void> _runTests() async {
const
int
numMessages
=
2500
;
final
BenchmarkResultPrinter
printer
=
BenchmarkResultPrinter
();
resetChannel
.
send
(
true
);
await
_runBasicStandardSmall
(
basicStandard
,
1
);
// Warmup.
printer
.
addResult
(
description:
'BasicMessageChannel/StandardMessageCodec/Flutter->Host/Small'
,
...
...
@@ -136,6 +141,7 @@ Future<void> _runTests() async {
unit:
'µs'
,
name:
'platform_channel_basic_standard_2host_small'
,
);
resetChannel
.
send
(
true
);
await
_runBasicStandardLarge
(
basicStandard
,
largeBuffer
,
1
);
// Warmup.
printer
.
addResult
(
description:
'BasicMessageChannel/StandardMessageCodec/Flutter->Host/Large'
,
...
...
@@ -144,6 +150,7 @@ Future<void> _runTests() async {
unit:
'µs'
,
name:
'platform_channel_basic_standard_2host_large'
,
);
resetChannel
.
send
(
true
);
await
_runBasicBinary
(
basicBinary
,
largeBufferBytes
,
1
);
// Warmup.
printer
.
addResult
(
description:
'BasicMessageChannel/BinaryCodec/Flutter->Host/Large'
,
...
...
@@ -151,6 +158,7 @@ Future<void> _runTests() async {
unit:
'µs'
,
name:
'platform_channel_basic_binary_2host_large'
,
);
resetChannel
.
send
(
true
);
await
_runBasicBinary
(
basicBinary
,
oneMB
,
1
);
// Warmup.
printer
.
addResult
(
description:
'BasicMessageChannel/BinaryCodec/Flutter->Host/1MB'
,
...
...
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