neuecc / UniRx

Reactive Extensions for Unity
MIT License
7.1k stars 889 forks source link

Named Operators #97

Closed neuecc closed 8 years ago

neuecc commented 9 years ago

I'm working in anonymous operator to named operator for performance improvement and readable stacktrace.

for example stack trace of below code are...

Observable.Return(1000)
    .Take(50)
    .Select(x => x)
    .Subscribe(x => Debug.Log(x));
// improvement version

UniRx.SubscribeObserver`1:OnNext(Int32) (at Assets/UniRx/Scripts/Observer.cs:147)
UniRx.Operators.SelectObserver:OnNext(Int32) (at Assets/UniRx/Scripts/Operators/Select.cs:79)
UniRx.Operators.TakeObserver:OnNext(Int32) (at Assets/UniRx/Scripts/Operators/Take.cs:62)
UniRx.Operators.ReturnObserver:OnNext(Int32) (at Assets/UniRx/Scripts/Operators/Return.cs:48)
UniRx.Operators.Return`1:SubscribeCore(IObserver`1, IDisposable) (at Assets/UniRx/Scripts/Operators/Return.cs:23)
UniRx.Operators.OperatorObservableBase`1:Subscribe(IObserver`1) (at Assets/UniRx/Scripts/Operators/OperatorObservableBase.cs:40)
UniRx.Operators.Take`1:SubscribeCore(IObserver`1, IDisposable) (at Assets/UniRx/Scripts/Operators/Take.cs:38)
UniRx.Operators.OperatorObservableBase`1:Subscribe(IObserver`1) (at Assets/UniRx/Scripts/Operators/OperatorObservableBase.cs:40)
UniRx.Operators.Select`2:SubscribeCore(IObserver`1, IDisposable) (at Assets/UniRx/Scripts/Operators/Select.cs:48)
UniRx.Operators.OperatorObservableBase`1:Subscribe(IObserver`1) (at Assets/UniRx/Scripts/Operators/OperatorObservableBase.cs:40)
UniRx.ObservableExtensions:Subscribe(IObservable`1, Action`1) (at Assets/UniRx/Scripts/Observer.cs:260)
UniRx.ObjectTest.UniRxTestSandbox:OnGUI() (at Assets/ObjectTest/UniRxTestSandbox.cs:354)
// current assetstore version

UniRx.AnonymousObserver`1:OnNext(Int32) (at Assets/UniRx/Scripts/Observer.cs:55)
UniRx.AnonymousObserver`1:OnNext(Int32) (at Assets/UniRx/Scripts/Observer.cs:55)
UniRx.<Select>c__AnonStoreyDE`2:<>m__1E0(Int32) (at Assets/UniRx/Scripts/Observable.cs:39)
UniRx.AnonymousObserver`1:OnNext(Int32) (at Assets/UniRx/Scripts/Observer.cs:55)
UniRx.AnonymousObserver`1:OnNext(Int32) (at Assets/UniRx/Scripts/Observer.cs:55)
UniRx.<Take>c__AnonStoreyA0`1:<>m__1A0(Int32) (at Assets/UniRx/Scripts/Observable.Paging.cs:28)
UniRx.AnonymousObserver`1:OnNext(Int32) (at Assets/UniRx/Scripts/Observer.cs:55)
UniRx.AnonymousObserver`1:OnNext(Int32) (at Assets/UniRx/Scripts/Observer.cs:55)
UniRx.<Return>c__AnonStorey71`1:<>m__183() (at Assets/UniRx/Scripts/Observable.Creation.cs:121)
UniRx.ImmediateScheduler:Schedule(Action) (at Assets/UniRx/Scripts/Schedulers/ImmediateScheduler.cs:26)
UniRx.<Return>c__AnonStorey70`1:<>m__D2(IObserver`1) (at Assets/UniRx/Scripts/Observable.Creation.cs:119)
UniRx.AnonymousObservable`1:Subscribe(IObserver`1) (at Assets/UniRx/Scripts/Observable.Creation.cs:46)
UniRx.ObservableExtensions:Subscribe(IObservable`1, Action`1, Action`1, Action) (at Assets/UniRx/Scripts/Observer.cs:173)
UniRx.<Take>c__AnonStorey9F`1:<>m__EB(IObserver`1) (at Assets/UniRx/Scripts/Observable.Paging.cs:23)
UniRx.AnonymousObservable`1:Subscribe(IObserver`1) (at Assets/UniRx/Scripts/Observable.Creation.cs:46)
UniRx.<Select>c__AnonStoreyDD`2:<>m__10A(IObserver`1) (at Assets/UniRx/Scripts/Observable.cs:27)
UniRx.<Subscribe>c__AnonStorey11F:<>m__210() (at Assets/UniRx/Scripts/Observable.Creation.cs:42)
UniRx.InternalUtil.ScheduledItem:Invoke() (at Assets/UniRx/Scripts/InternalUtil/ScheduledItem.cs:44)
UniRx.Trampoline:Run(SchedulerQueue) (at Assets/UniRx/Scripts/Schedulers/CurrentThreadScheduler.cs:122)
UniRx.CurrentThreadScheduler:Schedule(TimeSpan, Action) (at Assets/UniRx/Scripts/Schedulers/CurrentThreadScheduler.cs:91)
UniRx.CurrentThreadScheduler:Schedule(Action) (at Assets/UniRx/Scripts/Schedulers/CurrentThreadScheduler.cs:69)
UniRx.AnonymousObservable`1:Subscribe(IObserver`1) (at Assets/UniRx/Scripts/Observable.Creation.cs:42)
UniRx.ObservableExtensions:Subscribe(IObservable`1, Action`1) (at Assets/UniRx/Scripts/Observer.cs:158)
UniRx.ObjectTest.UniRxTestSandbox:OnGUI() (at Assets/ObjectTest/UniRxTestSandbox.cs:526)

Please wait a moment for easy to debug!

rest of operators list---

neuecc commented 9 years ago

More Improvment StackTrace.

stacktrace

This stacktrace indicates Where().Select().Take().Subscribe() Extremely clear and gets more performance!

neuecc commented 8 years ago

I've done all. I'll release next version(5.0) soon.

neuecc commented 8 years ago

New version is very fast.

Old: Subscribe = 457ms OnNext = 11ms

New: Subscribe = 38ms OnNext = 2.6ms

neuecc commented 8 years ago

Release UniRx 5.0.0.