Otto vs LocalBroadcast:

后端 未结 3 1279
無奈伤痛
無奈伤痛 2020-12-13 03:34

I am a huge fan of open source contributions square has done to the Android community and was looking into their latest contribution Otto (event bus )

http://square

3条回答
  •  天涯浪人
    2020-12-13 04:14

    Both Otto and LBM are within the same process space so in terms of speed i guess both would be same .

    I've found that registering Otto events are quite expensive, sometimes it takes more than 16 milliseconds to register event subscribers (That means you drop 1 FPS!). That's somewhat expected, as event subscribing in Otto is done by reflection. While for LBM, it only takes a few hundred µs only for registering, which is almost 32x faster. (Result from traceview, Samsung Galaxy S4)

    But of course, using Otto can write less code, there's a trade off.

提交回复
热议问题