Otto is another event bus library for Android; actually it's a fork of Guava's EventBus. greenrobot's EventBus and Otto share some basic semantics (register, post, unregister, ...), but there are differences which the following table summarizes:
EventBus | Otto | |
---|---|---|
Declare event handling methods | Annotations (since 3.0, can be precompiled for best performance) | Annotations |
Event inheritance | Yes | Yes |
Subscriber inheritance | Yes | No |
Cache most recent events | Yes, sticky events | No |
Event producers (e.g. for coding cached events) | No | Yes |
Event delivery in posting thread | Yes (Default) | Yes |
Event delivery in main thread | Yes | No |
Event delivery in background thread | Yes | No |
Asynchronous event delivery | Yes | No |
Note: the following information is outdated, preprocessed annotations are much faster than EventBus 2.x, on which the following table is based.
Besides features, performance is another differentiator. To compare performance, we created an Android application, which is also part of this repository (EventBusPerformance). You can also run the app on your phone to benchmark different scenarios.
TODO: Update for EventBus 3 with and without index.
Benchmark results indicate that EventBus is significantly faster in almost every scenario:
EventBus | Otto | |
---|---|---|
Posting 1000 events, Android 2.3 emulator | ~70% faster | |
Posting 1000 events, S3 Android 4.0 | ~110% faster | |
Register 1000 subscribers, Android 2.3 emulator | ~10% faster | |
Register 1000 subscribers, S3 Android 4.0 | ~70% faster | |
Register subscribers cold start, Android 2.3 emulator | ~350% faster | |
Register subscribers cold start, S3 Android 4.0 | About the same |
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。