NSNotificationCenter vs delegation - which is fast

2019-01-24 05:03发布

I have read a lot about the pros and cons of each , and i know delegates are usually for one listener, and notifications are for many. The question is about performance.

I have read this : NSNotificationCenter vs delegation( using protocols )?

I am sending audio signals from mic, to another class by notification . i know that here i should use the delegate BUT my question is : does delegates will be faster ? because i can see i have some frame rate issue(decreased), and i would like to know if the cause could be the using of notification instead of delegate, or there is no relation ?

7条回答
Viruses.
2楼-- · 2019-01-24 05:31

i know that here i should use the delegate BUT my question is : does delegates will be faster ?

It is easy: try and share the results!

The delegate when 1:1, point to point relationship can be faster than the 1:m publish and subscribe in any system.

Is it faster hard to answer, because it depends on environment. When aren't a lot of listeners and the publisher not need to search a lot for listeners, then should be similar performance, but when are a million of subscribers and need to search it, then can be a delay, frame rate decrease.

查看更多
登录 后发表回答