knaeckeKami / changenotifier_benchmark

15 stars 3 forks source link

Add stream benchmarks #6

Open tlvenn opened 3 years ago

tlvenn commented 3 years ago

Hi,

I know this is not exactly within the scope of benchmarking change notifier solutions but it is super interesting to see the tradeoffs with using streams as well. I believe the micro benchmark from getx was including some stream solutions and it was super interesting to see the results but the display of them was really poor and the broken english did not exactly help communicate those.

The 2 dimensions micro benchmark you put in place is much cleaner in that regard and the output table format is pretty clear.

Would love to see how stream implementations compare.

knaeckeKami commented 3 years ago

yeah, we can add also benchmarks for different streams. are there any additional concrete Stream implementations that you know of, except for Dart (sync/async) and the Getx ones?

tlvenn commented 3 years ago

Awesome, thanks again for putting those benchmarks in place to begin with. As for the streams, I am not aware of any others but the dart one and the 2 from Getx but that is probably a good starting point.

escamoteur commented 3 years ago

If you create the Dart Stream as synchronous they are way faster than the GetXStream. And the whole reason to use Streams is asynchronous behavior which is not the case with GetX streams. The real replacement would be using ChangeNotifiers together with functional_listener.

tlvenn commented 3 years ago

Ya that's a fair point and a big difference between ChangeNotifiers / Observables (Sync) and Streams (Async). It seems there are also good reasons when you might want to use synchronous streams when you care about latency:

image

For example, it would seem that if you have a websocket and you are piping received events on a stream dedicated to it (Only producer is the ws handler), it could improve the latency a bit by using the synchronous stream controller as to skip a microtask for each event push.