简体   繁体   English

番石榴在Android应用中的EventBus组件性能

[英]Guava's EventBus component performance in Android app

I am prototyping an application and I though I would try to use Guava's EventBus component to get rid of some code I was keeping writing again and again to propagate events from fragments to activities for instance. 我正在为一个应用程序制作原型,尽管我会尝试使用Guava的EventBus组件来摆脱一些代码,但我一直在不断编写,以将事件从片段传播到活动。

To my surprise, I got a really big performance hit when activities are starting. 令我惊讶的是,活动开始时我的表现受到了很大的打击。

I only do a single EventBus.register call on the activity itself. 我仅对活动本身执行一个EventBus.register调用。 Removing that call brings back the activity start time to usual. 删除该呼叫可使活动开始时间恢复为正常。 I also noticed quite a lot of garbage collection going on at that time. 我还注意到当时进行了很多垃圾回收。

Would anyone have advice about Guava's EventBus and Android? 有人会提供有关Guava EventBus和Android的建议吗? Should I simply go back to the simple fragment listener pattern? 我是否应该简单地回到简单的片段侦听器模式? Any other library (I was about to try mbassador too, but I am running out of prototyping time). 其他任何图书馆(我也打算尝试使用mbassador,但我的原型开发时间已用完)。

I ended up simply not using any event bus implementation by lack of time (and the project is small, so it was more of a personal experimentation). 由于时间紧迫,我最终没有使用任何事件总线实现(该项目很小,因此更多是个人实验)。

However, there are a number of alternatives to Guava's EventBus as said by L. Wasserman: Square's Otto , mbassador , ... 但是,正如L. Wasserman所说,番石榴的EventBus有很多替代品: Square的Ottombassador ,...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM