-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
performance question, For example, there are 10 NSString parameters #23
Comments
See this article: http://yulingtianxia.com/blog/2019/11/28/DartObjC-Design/ We should do more tests. |
because I want to get some native information through methodchannel before runApp(), but methodchannel has some problems, so I am also looking at ffi-related methods. I read your article that the performance has been greatly improved. I think the performance problem of methodchannel should be Is it the encode/decode byteDate and match to the channel? I think dart-native create objects is also very performance consuming? class RealChannel {
static const MethodChannel _channel =
const MethodChannel('dart_native');
static Future<String> get platformVersion async {
final String version = await _channel.invokeMethod('getPlatformVersion',["xxxx", 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx']);
return version;
}
}
final time = DateTime.now().millisecondsSinceEpoch;
for (int i = 0; i < 10000; i++) {
final value = await RealChannel.platformVersion;
print(value);
}
/// 4568ms
print("------------ channel ${DateTime.now().millisecondsSinceEpoch - time}");
final time2 = DateTime.now().millisecondsSinceEpoch;
for (int i = 0; i < 10000; i++) {
stub.fooCompletion('xxx', 'xxxx', 'xxxxxx', 'xxxxxx', (NSString value) {
print(value.raw);
});
}
/// 5768ms
print("------------ native ${DateTime.now().millisecondsSinceEpoch - time2}");
final time3 = DateTime.now().millisecondsSinceEpoch;
for (int i = 0; i < 10000; i++) {
stub.fooCompletion1((NSString value) {
print(value.raw);
});
}
/// 3639ms
print("------------ native2 ${DateTime.now().millisecondsSinceEpoch - time3}");
|
Converting a Dart |
ok,thanks!learned a lot in this project~ |
Thank you for using DartNative. We are still developing and optimizing. |
When there are many parameters and there is also a callback, multiple parameter objects and block objects are created every time the method is called, so is it really faster than the method channel? do you have a test?
The text was updated successfully, but these errors were encountered: