Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
RXJS 6 vs Vanilla #2
(version: 0)
Comparing performance of:
RXJS vs Vanilla
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://d3js.org/d3.v5.min.js"></script> <script src='https://unpkg.com/rxjs@6.5.5/bundles/rxjs.umd.min.js'></script>
Script Preparation code:
var rawdata = [{"rect":{"y":80.39215686274508,"width":79.10307898259705,"height":17.64705882352941},"value":5909,"label":{"value":"2020-01-27 15:52:39.000","x":39.55153949129853,"y":89.21568627450979}},{"rect":{"y":60.784313725490186,"width":104.99330655957162,"height":17.64705882352941},"value":7843,"label":{"value":"2019-11-11 20:55:13.000","x":52.49665327978581,"y":69.60784313725489}},{"rect":{"y":41.17647058823529,"width":107.1619812583668,"height":17.64705882352941},"value":8005,"label":{"value":"2020-04-14 18:29:52.000","x":53.5809906291834,"y":49.99999999999999}},{"rect":{"y":21.56862745098039,"width":137.46987951807228,"height":17.64705882352941},"value":10269,"label":{"value":"2020-01-22 15:48:25.000","x":68.73493975903614,"y":30.392156862745097}},{"rect":{"y":1.9607843137254903,"width":270,"height":17.64705882352941},"value":20169,"label":{"value":"2020-01-03 19:09:13.000","x":135,"y":10.784313725490195}}]; var x = d3.scaleLinear().range([0, 300]); var y = d3.scaleBand().range([250, 0]).padding(0.1);
Tests:
RXJS
let { from, Observable } = rxjs; let { flatMap, map, tap, toArray } = rxjs.operators; var data$ = from(rawdata) .pipe( toArray(), map(values => values.sort((a, b) => b.value - a.value).reverse().slice(0, 5)), tap((values) => { x = x.domain([0, d3.max(values, d => d.value)]); y = y.domain(values.map((d) => d.label)); }), flatMap(values => values), map(bar => ({ rect: { y: y(bar.label), width: x(bar.value), height: y.bandwidth() }, value: bar.value, label: { value: bar.label, x: x(bar.value) <= 300 / 5 ? x(bar.value) + 10 : x(bar.value) / 2, y: y(bar.label) + y.bandwidth() / 2 } })), toArray() ); let data; data$.subscribe(d => data = d);
Vanilla
let values = rawdata.sort((a, b) => b.value - a.value).reverse().slice(0, 5); // Set x and y values x = x.domain([0, d3.max(values, d => d.value)]); y = y.domain(values.map((d) => d.label)); // Set bars on chartmap var data = values.map(bar => ({ rect: { y: y(bar.label), width: x(bar.value), height: y.bandwidth() }, value: bar.value.toString(), label: { value: bar.label, x: x(bar.value) <= 300 / 5 ? x(bar.value) + 10 : x(bar.value) / 2, y: y(bar.label) + y.bandwidth() / 2 } }))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
RXJS
Vanilla
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 break down the provided benchmark definition and explain what's being tested, compared options, pros and cons of each approach, and other considerations. **Benchmark Definition:** The benchmark measures the performance difference between using Reactive Extensions (RXJS) version 6 and vanilla JavaScript for data processing and visualization on a dataset of rectangles with varying y-coordinates, widths, heights, values, and labels. **Tested Options:** Two test cases are compared: 1. **RXJS**: Uses RXJS version 6 to process the dataset and visualize it using D3.js. 2. **Vanilla**: Uses vanilla JavaScript without any libraries or frameworks to process the dataset and visualize it using D3.js. **Approaches:** **RXJS (Version 6)** * Pros: + Uses Reactive Programming principles, which can lead to more efficient and scalable data processing. + Provides a concise and expressive way to handle asynchronous operations and data transformations. + Leverages the power of observables and operators to simplify data manipulation. * Cons: + Requires additional setup and learning curve due to its functional programming style. + May introduce overhead due to the creation of observable subscriptions. **Vanilla (JavaScript)** * Pros: + No external dependencies or libraries required, making it a lightweight solution. + Easy to learn and use for developers familiar with JavaScript. + Can be optimized for performance by using techniques like loop unrolling and caching. * Cons: + Requires more manual effort and expertise in data manipulation and visualization. + May lead to more complex code due to the absence of higher-order functions. **D3.js** Both test cases use D3.js for data visualization, which provides a powerful and flexible way to create interactive charts. However, the performance difference between RXJS and vanilla JavaScript will still be influenced by how efficiently each option processes and transforms the data. **Library: d3-scale** The benchmark definition includes a section using `d3-scale`, specifically `x` and `y`. These scales are used for data scaling and mapping. No special mention of this library is necessary as it's part of D3.js and not an external dependency that requires explanation beyond its intended purpose. **Special JS Features:** No specific JavaScript features or syntax are highlighted in the benchmark definition, which suggests that these aspects might be already accounted for in the provided benchmarks or not significant enough to warrant separate attention. **Alternatives:** Alternative approaches could include: * Using a different data visualization library, such as Chart.js, Highcharts, or Plotly. * Employing alternative data processing techniques, like MapReduce, Spark, or Web Workers. * Implementing the benchmark using a different programming language or runtime environment (e.g., Node.js vs. browser JavaScript). However, the focus of this specific benchmark is on comparing RXJS and vanilla JavaScript for data processing and visualization tasks using D3.js.
Related benchmarks:
max-or-flat
111111111111111
Test_Currency
Test_Currency111
Create new
Comments
Confirm delete:
Do you really want to delete benchmark?