Skip to content

jinyus/rainbench

Repository files navigation

Rainbench is designed to test the throughput of different reactive libraries. It's a simple benchmark that fills a bucket with raindrops.

Each rain drop creates a subscription, and the observable gets updated every millisecond, which should trigger a rebuild of each rain drop widget with its new position.

The number of raindrops and the capacity of the bucket can be adjusted. The benchmark will run until the bucket is full. The time it takes to fill the bucket is recorded and displayed at the end of the benchmark.

Note

This is a stress test so don't put too much stock in the results as real apps will typically have a lot less updates/subscriptions.

Results

  • Release mode on linux
  • The benchmark is restarted after each run to prevent GC interference
  • value_LB == value_listenable_builder
  • stream_builder and value_LB are not perfect comparisons as they can only listen to 1 observable at a time... but they serve as a good baseline
  • solidart implementation uses SolidBuilder which can only listen to a fixed number of observables so it's not a perfect comparison either.

20k raindrops and a bucket capacity of 30k

Library Raindrops/s Time to fill bucket
state_beacon 5337 5.62s
value_LB 5030 5.96s
mobx 4618 6.50s
solidart 3843 7.81s
signals 2011 14.91s
stream_builder 1461 20.52s
context_watch 1209 24.80s

Video:

20k-e1f244e13dc3ea79b5b21419c0cd13f3f1cd42d9.mp4

RydMike - Updated test runs (Feb 3, 2024)

  • Updated to use the latest version of each library
  • Added Signals option to use Watch instead of context.watch.
  • Fixed capability to actually select the option to use ValueNotifier with State Beacon.
  • Tested in release mode on macOS (M1 Pro), with Flutter 3.16.9.
  • The benchmark is restarted after each run to prevent GC interference.
  • Used 20k raindrops and a bucket capacity of 200k for longer tests.

20k raindrops and a bucket capacity of 200k

Library Raindrops/s Time to fill bucket
1 state_beacon 20288 9.9s
2 mobx 12934 15.5s
3 state_beacon VN 9467 21.1s
4 value_LB (Throws exceptions after completion!!!) 9450 21.1s
5 solidart 9466 21.1s
6 signals Watch 8662 23.1s
7 signals context(watch) 7843 25.5s
8 context_watch 5504 36.3s
9 stream_builder 4549 44.0s

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published