vs RxJS
SYSTEM CONFIGURATION:
- CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (6 cores / 12 threads)
- Memory: 32Go
- OS: Ubuntu 20.04 LTS
- Browser: Chrome 109
- Date: 2023-01-26
- @lirx/core: 1.2.0
- rxjs: 7.5.6
Benchmark 1
This first benchmark compares the 3 most common and used pipes: map
, filter
and distinctUntilChanged
.
rxjs | @lirx/core | ratio | |
---|---|---|---|
time | 1250ms | 247ms | 5x faster |
size | 12.02kb | 0.50kb | 24x smaller |
(gzipped) | 4.27kb | 0.29kb | 14.7x smaller |
As you may see, @lirx/core
strongly outperforms RxJS
in both execution time and bundle size.
And due to its capabilities, you may use it in any of your projects with almost zero footprint.
Let's note however, that RxJS
did an amazing job this past years, as they went from 20x slower a few years ago at 5x slower for the same test code.
Expand the code
Benchmark 2
This benchmark focuses more on the notifications, and the performances associated with them.
rxjs | @lirx/core (with notification) | ratio | @lirx/core (without notification) | ratio | |
---|---|---|---|---|---|
time | 3713ms | 2379ms | 1.56x faster | 1112ms | 3.3x faster |
size | 14.3kb | 1.37kb | 10.4x smaller | 0.56kb | 25.5x smaller |
(gzipped) | 4.95kb | 0.66kb | 7.5x smaller | 0.32kb | 15.4x smaller |
This time, RxJS
performs pretty well. It has been built for Observables having states.
So it is finely tuned for these cases. @lirx/core
is the winner, but by little (~30% less time).
However, if we rewrite the pipeline to work without Notifications, we may see than @lirx/core
takes the lead.
Through this example, we may see that it's pretty important to select the right Observable and pipeline, as it could easily double our performances.