cujojs / most

Ultra-high performance reactive programming
MIT License
3.49k stars 231 forks source link

Have you considered testing static pipelines as well in the perf tests? #522

Closed dead-claudia closed 5 years ago

dead-claudia commented 5 years ago

To give a concrete example, consider the code here. You could probably see some serious perf differences if you replicated the tests for the ones that support cold observables, using static pipelines instead of dynamically created ones as much as possible. Of course, you can see below you can't do it always, but for cold subscription-only observables, I think the relative speeds might be closer together. (Plus, it's this part that RxJS focuses on in performance, not the creation part.)

mostPipeline = most.from(a).filter(even).map(add1)
rxPipeline = rx.Observable.fromArray(a).filter(even).map(add1)
rx5Pipeline = rxjs.Observable.from(a).filter(even).map(add1)
xstreamPipeline = xs.fromArray(a).filter(even).map(add1).fold(sum, 0)
kefirPipeline = kefirFromArray(a).filter(even).map(add1).scan(sum, 0)
baconPipeline = bacon.fromArray(a).filter(even).map(add1)
highlandPipeline = highland(a).filter(even).map(add1)

suite
  .add('most', function(deferred) {
    runners.runMost(deferred, mostPipeline.reduce(sum, 0));
  }, options)
  .add('rx 4', function(deferred) {
    runners.runRx(deferred, rxPipeline.reduce(sum, 0));
  }, options)
  .add('rx 5', function(deferred) {
    runners.runRx5(deferred, rx5Pipeline.reduce(sum, 0));
  }, options)
  .add('xstream', function(deferred) {
    runners.runXstream(deferred, xstreamPipeline.last());
  }, options)
  .add('kefir', function(deferred) {
    runners.runKefir(deferred, kefirPipeline.last());
  }, options)
  .add('bacon', function(deferred) {
    runners.runBacon(deferred, baconPipeline.reduce(0, sum));
  }, options)
  .add('highland', function(deferred) {
    runners.runHighland(deferred, highlandPipeline.reduce(0, sum));
  }, options);

One other suggestion: RxJS 6 could be a good addition, too. They've made some serious API changes, and I think perf has been substantially changed, too.

briancavalier commented 5 years ago

Hi @isiahmeadows. I had tried it at one point and from what I remember, the creation time was completely dominated by the run time. That said, I'd certainly welcome a PR that adds these kinds of tests, as well as one that adds rx 6. It's good to see the progress the rx team has made since v4.

briancavalier commented 5 years ago

Closing because of inactivity. Please feel free to reopen with an update.