Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Rxjs several pipes vs one 100k without functional array functions at all
(version: 0)
Comparing performance of:
RxJS one pipe vs Several pipes
Created:
3 years ago
by:
Registered User
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.forEach(value => { value = value * 2; if (value % 3 === 0) { 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);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
RxJS one pipe
Several pipes
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser/OS:
Chrome 134 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
RxJS one pipe
187929.0 Ops/sec
Several pipes
236975.6 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the benchmark. **What is being tested?** The provided benchmark tests two approaches for processing data using RxJS (Reactive Extensions for JavaScript), a library for reactive programming: 1. **RxJS one pipe**: This approach uses a single `map` operator to transform and filter the data in one step. 2. **Several pipes**: This approach breaks down the transformation into multiple smaller operators, such as `map`, `filter`, and another `map`. **What are the options being compared?** The two options being compared are: 1. Processing 100,000 numbers using a single `map` operator. 2. Processing 100,000 numbers using three separate `map` operators in sequence. **Pros and cons of each approach:** * **RxJS one pipe**: This approach is likely to be faster since it only involves a single operation. However, if the transformation or filtering logic becomes more complex, this approach may not scale well. + Pros: Single operation, potentially faster + Cons: May not handle complex transformations or filtering well * **Several pipes**: This approach breaks down the transformation into smaller steps, which can make it easier to understand and maintain. However, it may be slower due to the additional operations. + Pros: Easier to understand and maintain, potentially less error-prone + Cons: May be slower due to multiple operations **Library usage** The benchmark uses RxJS library version 6.5.5. **Special JS feature or syntax** There is no special JavaScript feature or syntax being used in this benchmark. **Other considerations** * **Data structure**: The data is processed using a `Map` object, which may have performance implications. * **Caching**: It's possible that the results are cached between executions, which could affect the accuracy of the benchmark. * **Environment**: The benchmark is run on a Chrome 110 browser on a Mac OS X 10.15.7 desktop. **Alternatives** Other alternatives for processing data using RxJS include: 1. Using `forEach` and iterating over the array manually. 2. Using other operators, such as `reduce`, `forEachMap`, or `flatMap`. 3. Using a different library, such as Lodash or Ramda. These alternatives may have different performance characteristics and trade-offs in terms of readability and maintainability.
Related benchmarks:
For loop map vs map builtin for 10000000 elements
For loop map vs map builtin for 100000 elements
Splice vs Spread + Slice
test reduce with rest vs from entries vs reduce without new object2
Object.entries vs Generator
Comments
Confirm delete:
Do you really want to delete benchmark?