Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Rxjs several pipes vs one 100k with entries v2
(version: 0)
Comparing performance of:
RxJS one pipe vs Several pipes vs RxJS one pipe from entries vs RxJS many pipes from entries
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://unpkg.com/rxjs@6.5.5/bundles/rxjs.umd.min.js'></script>
Script Preparation code:
var rawdata = Array.from(Array(100000).keys()) // 10k numbers 1,2,3,4,5...
Tests:
RxJS one pipe
let { from, Observable } = rxjs; let { flatMap, map, tap, toArray } = rxjs.operators; const data$ = from(rawdata) .pipe( map(values => { const finalValues = new Map(); values.map(value => value * 2) .filter(value => value % 3 === 0) .forEach(value => finalValues.set(value.toString(), value)) return finalValues; }) ) let data; data$.subscribe(d => data = d);
Several pipes
let { from, Observable } = rxjs; let { flatMap, map, tap, toArray } = rxjs.operators; const data$ = from(rawdata) .pipe( map(values => values.map(value => value * 2)), map(values => values.filter(value => value % 3 === 0)), map(values => { const finalValues = new Map(); values.forEach(value => finalValues.set(value.toString(), value)); return finalValues; }) ) let data; data$.subscribe(d => data = d);
RxJS one pipe from entries
let { from, Observable } = rxjs; let { flatMap, map, tap, toArray } = rxjs.operators; const data$ = from(rawdata) .pipe( map(values => { return new Map(values.map(value => value * 2) .filter(value => value % 3 === 0) .map(value => [value.toString(), value])); }) ) let data; data$.subscribe(d => data = d);
RxJS many pipes from entries
let { from, Observable } = rxjs; let { flatMap, map, tap, toArray } = rxjs.operators; const data$ = from(rawdata) .pipe( map(values => values.map(value => value * 2)), map(values => values.filter(value => value % 3 === 0)), map(values => { return new Map(values.map(value => [value.toString(), value])); }) ) let data; data$.subscribe(d => data = d);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
RxJS one pipe
Several pipes
RxJS one pipe from entries
RxJS many pipes from entries
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of RxJS microbenchmarks on MeasureThat.net. **What is tested?** The provided benchmark tests different approaches to transforming and filtering data in an RxJS pipeline, specifically when working with large datasets (in this case, 100,000 numbers). The benchmarks compare the performance of various combinations of RxJS operators: 1. **RxJS one pipe**: A single pipeline with multiple operators applied sequentially. 2. **Several pipes**: Multiple pipelines, each with a different set of operators. 3. **RxJS one pipe from entries**: Similar to the first option, but using `from(entries)` instead of traditional data source. 4. **RxJS many pipes from entries**: Multiple pipelines with different sets of operators, using `from(entries)`. **Options compared** Here's a brief overview of each option: * **RxJS one pipe**: Sequential application of multiple operators (map, filter, etc.) in the same pipeline. * Pros: Can be easier to understand and maintain than more complex pipelines. Some operators can be combined or reused. * Cons: May lead to slower performance due to the sequential nature of the operations. * **Several pipes**: Multiple parallel pipelines with different sets of operators applied. * Pros: Can lead to better performance, as some operators can be executed in parallel. Reduces the complexity of individual pipeline components. * Cons: More complex to understand and maintain, especially when dealing with multiple pipelines. * **RxJS one pipe from entries**: Using `from(entries)` instead of traditional data source for the pipeline. * Pros: Can simplify the creation of pipelines by avoiding explicit data source management. Reduces memory usage since only necessary data is processed at once. * Cons: May lead to slower performance due to the overhead of creating and managing a new observable from entries. **Special JS features** There's no specific special JavaScript feature being tested here, as the focus is on RxJS operators and their performance. However, it's worth noting that `from(entries)` can be used in other contexts beyond this benchmark. **Benchmark preparation code and HTML setup** The provided script preparation code sets up an array of 100,000 numbers (`rawdata`) and a reference to the RxJS library (rxjs). The HTML setup includes linking to the RxJS library using `<script src='https://unpkg.com/rxjs@6.5.5/bundles/rxjs.umd.min.js'></script>`. **Other alternatives** If you're interested in optimizing your own RxJS pipelines, consider exploring: * **RxJS caching**: Using RxJS operators like `shareReplay` or `refCount` to cache and reuse observables. * **Just-In-Time (JIT) compilation**: Some libraries like `rxjs-jit` can compile parts of the pipeline at runtime for better performance. * **Native code**: Some advanced use cases may involve compiling RxJS pipelines into native machine code, such as with WebAssembly. Keep in mind that the best approach depends on your specific use case and performance requirements. MeasureThat.net's benchmark results provide a good starting point for understanding the relative performance of different RxJS pipeline approaches.
Related benchmarks:
Rxjs several pipes vs one 100k
Rxjs several pipes vs one 100k without functional array functions at all
Rxjs several pipes vs one 100k without functional array functions at all qwerq
Rxjs several pipes vs one 100k without functional array functions at all 123sdfaasd
Comments
Confirm delete:
Do you really want to delete benchmark?