Comments (4)
Hi Stéphane,
Thanks for your request. I have already thought about this option and here is what I came to. There are three main operations to be implemented.
- Find all subscriber and provider methods of all registered callback objects.
- Find all callback objects registered for a particular event.
- Dispatch an event to all registered callbacks.
Operation 1 can be optimized by using annotation processor. At the same time this is one-time operation. It's executed only once, when a callback is registered for the first time. The possible performance gain can be only expected on application start-up, which is not bad.
Operation 2 cannot be optimized due to dynamic nature of callbacks. Callbacks are registered / unregistered in any sequence. A dynamic structure similar to the one I use now is still required.
Operation 3 can be optimized by using annotation processor. Generated event dispatch method will contain a sequence of if-else statements calling certain callback's method depending on the event type, which in worst case will have O(n) code complexity. Right now I use a HashMap with quite constant O(1) complexity. I'm not sure whether direct Java calls can compensate much this comparing to a reflection calls I do now.
My conclusion was like this. Before I start to optimized something I need to exactly know where are the bottlenecks. It would be interesting to see some numbers showing slow application start-up or slow event dispatching.
I'm not saying this is not needed at all. Bus as for now, I would say this has lower priority than other tasks.
from tinybus.
I found some more stuff on this. Jake worked on a AnnotationProcessor for Otto library about two years ago and he stopped to push this branch forward.
https://github.com/square/otto/tree/jw/code-gen/library/src/main/java/com/squareup/otto/internal
There must be some reasons for that. I suspect it's because resulting gain was not worth the effort. But I might be wrong. Let's close this issue for now and once we have a clear need for such optimization we can revisit it and reopen it again.
from tinybus.
I think you underestimate the gain of not using reflection. But nw, it's
your lib. ;)
2014-11-17 14:31 GMT-08:00 Sergej Shafarenka [email protected]:
I found some more stuff on this. Jake worked on a AnnotationProcessor for
Otto library about two years ago and he stopped to push this branch forward.https://github.com/square/otto/tree/jw/code-gen/library/src/main/java/com/squareup/otto/internal
There must be some reasons for that. I suspect it's because resulting gain
was not worth the effort. But I might be wrong. Let's close this issue for
now and once we have a clear need for such optimization we can revisit it
and reopen it again.—
Reply to this email directly or view it on GitHub
#19 (comment).
from tinybus.
Btw, Jake can be reached if you need to.. you can maybe ping him via the
Otto issue page, talk about your lib and ask why the annotation processor
has been abandoned.
2014-11-17 14:33 GMT-08:00 Stéphane NICOLAS [email protected]:
I think you underestimate the gain of not using reflection. But nw, it's
your lib. ;)2014-11-17 14:31 GMT-08:00 Sergej Shafarenka [email protected]:
I found some more stuff on this. Jake worked on a AnnotationProcessor for
Otto library about two years ago and he stopped to push this branch forward.
https://github.com/square/otto/tree/jw/code-gen/library/src/main/java/com/squareup/otto/internal
There must be some reasons for that. I suspect it's because resulting
gain was not worth the effort. But I might be wrong. Let's close this issue
for now and once we have a clear need for such optimization we can revisit
it and reopen it again.—
Reply to this email directly or view it on GitHub
#19 (comment).
from tinybus.
Related Issues (20)
- Remove delayed events when bus gets destroyed
- add travis build
- Android minSdkVersion HOT 1
- @Subscribe visibility? HOT 5
- Generate warnings for not public handler methods HOT 6
- can tinybus support process crossing? HOT 2
- subclasses do not receive events? HOT 1
- Is TinyBus library minSdkVersion 14? HOT 1
- TinyBus can't deliver large objects? HOT 4
- Any reason for such high minimum sdk?
- Not enough information in error message
- Exception on activity start
- java.lang.NoClassDefFoundError: android/os/PersistableBundle crash HOT 4
- Calling unregister() on an unregistered object throws NPE
- Can support for activity post to another activity like eventbus? HOT 2
- Tinybus Android Studio Plugin HOT 1
- Only last event gets delivered when posting multiple events via .postDelayed() HOT 3
- Build system is broken, Pull requests cannot be merge due to that
- java.lang.RuntimeException HOT 6
- Tinybus Intellij Plugin
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinybus.