Skip to content

Commit

Permalink
Extend doc with extended example (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
victimsnino authored Dec 16, 2023
1 parent 84e2b24 commit 14fcc97
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 1 deletion.
61 changes: 60 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Try out rpp on [godbolt.org](https://godbolt.org/z/48fh1hcbn)!

## Documentation:

Refer to [User Guide](https://victimsnino.github.io/ReactivePlusPlus/v2/docs/html/md_docs_2readme.html) for better understanding of concepts of Reactive Programming and [API Reference of RPP](https://victimsnino.github.io/ReactivePlusPlus/v2/docs/html/group__rpp.html) itself.
Check [User Guide](https://victimsnino.github.io/ReactivePlusPlus/v2/docs/html/md_docs_2readme.html) and [API Reference of RPP](https://victimsnino.github.io/ReactivePlusPlus/v2/docs/html/group__rpp.html).

## Note about V2:
Currently I'm working on RPP v2 (`v2` branch). RPP v2 follows [**"zero-overhead principle"**](https://en.cppreference.com/w/cpp/language/Zero-overhead_principle) and most of the operators are (and will) minimize overhead.
Expand Down Expand Up @@ -61,6 +61,65 @@ rpp::source::from_callable(&::getchar)
There we are creating observable which emits value via invoking of `getchar` function, then `repeat`s it infinite amount of time till termination event happes. It emits values while symbol is not equal to `0`, takes only not digits, maps them to upper case and then just prints to console.
## Why do you need it?
Check the [User Guide](https://victimsnino.github.io/ReactivePlusPlus/v2/docs/html/md_docs_2readme.html) for a detailed overview of the Reactive Programming concept and RPP itself.
In short, RPP can help you build complex pipelines to distribute values over time, connect "some sources of data" without directly connecting them.
Take a look at the example code for using RPP with QT. Here, you can see how to connect a button to a label and update it based on the number of clicks.
```cpp
auto button = new QPushButton("Click me!");
auto clicks_count_label = new QLabel();
QObject::connect(button, &QPushButton::clicked, [&clicks_count_label, count = 0]() mutable {
clicks_count_label->setText(QString{"Clicked %1 times!"}.arg(++count));
});
```

In this example, the button is directly connected to the label. What if you want to link another widget to the same button?

```cpp
auto button = new QPushButton("Click me!");
auto clicks_count_label = new QLabel();
auto clicks_duration_label = new QLabel();
QObject::connect(button, &QPushButton::clicked, [&clicks_count_label, count = 0]() mutable {
clicks_count_label->setText(QString{"Clicked %1 times!"}.arg(++count));
});
QObject::connect(button, &QPushButton::clicked, [&clicks_duration_label, now = std::chrono::high_resolution_clock::now()]() mutable {
const auto old = std::exchange(now, std::chrono::high_resolution_clock::now());
clicks_duration_label->setText(QString{"MS since last click %1!"}.arg(std::chrono::duration_cast<std::chrono::milliseconds>(now-old).count()));
});
```
Again directly connected... and it becomes a bit complex.. what if i want to accumulate two buttons at the same time? should i make a separate variable for this case? Build complex state to track it? Ideally it would be nice also to update "MS since last click %1!" at runtime each 1ms... So, looks like each label have to depend on multiple sources of data. It is not a trivial case. In this case it is nice opportunity to try RPP!
```cpp
auto button_1 = new QPushButton("Click me!");
auto button_2 = new QPushButton("Click me!");
auto clicks_count_label = new QLabel();
auto clicks_duration_label = new QLabel();
const auto clicks_1 = rppqt::source::from_signal(*button_1, &QPushButton::clicked);
const auto clicks_2 = rppqt::source::from_signal(*button_2, &QPushButton::clicked);
const auto merged_clicks = clicks_1 | rpp::operators::merge_with(clicks_2);
const auto total_clicks = merged_clicks | rpp::operators::scan(0, [](int seed, auto) { return ++seed; });
const auto click_times = merged_clicks | rpp::operators::map([](auto) { return std::chrono::high_resolution_clock::now(); });
const auto time_since_click = rpp::source::interval(std::chrono::milliseconds{1}, rppqt::schedulers::main_thread_scheduler{})
| rpp::operators::with_latest_from([](auto, const auto click_time) { return std::chrono::high_resolution_clock::now() - click_time; }, click_times);
// .....
total_clicks.subscribe([&clicks_count_label](int clicks)
{
clicks_count_label->setText(QString{"Clicked %1 times in total!"}.arg(clicks));
});
time_since_click.subscribe([&clicks_duration_label](std::chrono::high_resolution_clock::duration ms) {
clicks_duration_label->setText(QString{"MS since last click %1!"}.arg(std::chrono::duration_cast<std::chrono::milliseconds>(ms).count()));
});
```
Now we have separate observables for separate sources of dynamic data like clicks itself, clicks count and time of clicks. As a result, we can combine them in any way we want. At the same time now observables and actions for events can be separated easily - we have "some observable of some clicks or any counted event" and "some observable of durations". How this observables was obtained - doesn't matter. Also we easily built a much more complex pipeline without any difficulties.


# Useful links
- [User Guide](https://victimsnino.github.io/ReactivePlusPlus/v2/docs/html/md_docs_2readme.html)
- [API Reference](https://victimsnino.github.io/ReactivePlusPlus/v2/docs/html/group__rpp.html)
Expand Down
1 change: 1 addition & 0 deletions src/examples/rppqt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# add_subdirectory(interactive_window)
add_subdirectory(basic)
add_subdirectory(doxygen)
# add_subdirectory(multi_threaded)
5 changes: 5 additions & 0 deletions src/examples/rppqt/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_executable(basic_rppqt basic_rppqt.cpp)
target_link_libraries(basic_rppqt PRIVATE rpp rppqt)
set_target_properties(basic_rppqt PROPERTIES FOLDER Examples/rppqt)
rpp_add_qt_support_to_executable(basic_rppqt)

51 changes: 51 additions & 0 deletions src/examples/rppqt/basic/basic_rppqt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <rpp/rpp.hpp>
#include <rppqt/rppqt.hpp>

#include <QApplication>
#include <QMainWindow>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLabel>

int main(int argc, char* argv[])
{
QApplication app{argc, argv};

auto button_1 = new QPushButton("Click me!");
auto button_2 = new QPushButton("Click me!");
auto clicks_count_label = new QLabel();
auto clicks_duration_label = new QLabel();

const auto clicks_1 = rppqt::source::from_signal(*button_1, &QPushButton::clicked);
const auto clicks_2 = rppqt::source::from_signal(*button_2, &QPushButton::clicked);
const auto merged_clicks = clicks_1 | rpp::operators::merge_with(clicks_2);

const auto total_clicks = merged_clicks | rpp::operators::scan(0, [](int seed, auto) { return ++seed; });
const auto click_times = merged_clicks | rpp::operators::map([](auto) { return std::chrono::high_resolution_clock::now(); });
const auto time_since_click = rpp::source::interval(std::chrono::milliseconds{1}, rppqt::schedulers::main_thread_scheduler{})
| rpp::operators::with_latest_from([](auto, const auto click_time) { return std::chrono::high_resolution_clock::now() - click_time; }, click_times);

// .....

total_clicks.subscribe([&clicks_count_label](int clicks)
{
clicks_count_label->setText(QString{"Clicked %1 times in total!"}.arg(clicks));
});


time_since_click.subscribe([&clicks_duration_label](std::chrono::high_resolution_clock::duration ms) {
clicks_duration_label->setText(QString{"MS since last click %1!"}.arg(std::chrono::duration_cast<std::chrono::milliseconds>(ms).count()));
});

QMainWindow window{};
auto vbox = new QVBoxLayout();
vbox->addWidget(button_1);
vbox->addWidget(button_2);
vbox->addWidget(clicks_count_label);
vbox->addWidget(clicks_duration_label);
window.setCentralWidget(new QWidget);
window.centralWidget()->setLayout(vbox);
window.show();

return app.exec();
}

1 comment on commit 14fcc97

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BENCHMARK RESULTS (AUTOGENERATED)

ci-ubuntu-gcc

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 302.85 ns 1.55 ns 1.23 ns 1.25
Subscribe empty callbacks to empty observable via pipe operator 302.50 ns 1.54 ns 1.23 ns 1.25

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 702.10 ns 0.62 ns 0.62 ns 1.00
from array of 1 - create + subscribe + current_thread 1030.86 ns 4.63 ns 4.63 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 2291.73 ns 79.11 ns 79.86 ns 0.99
defer from array of 1 - defer + create + subscribe + immediate 729.66 ns 0.31 ns 0.31 ns 1.00
interval - interval + take(3) + subscribe + immediate 2128.84 ns 58.03 ns 58.01 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3017.23 ns 32.12 ns 32.10 ns 1.00

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1206.17 ns 0.31 ns 0.31 ns 1.00
immediate_just+filter(true)+subscribe 831.65 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 983.94 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 854.43 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+first()+subscribe 1226.97 ns 0.62 ns 0.62 ns 1.00
immediate_just(1,2)+last()+subscribe 916.14 ns 0.31 ns 0.31 ns 1.00
immediate_just+take_last(1)+subscribe 1132.84 ns 18.53 ns 19.35 ns 0.96

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 274.44 ns 1.54 ns 1.24 ns 1.25
current_thread scheduler create worker + schedule 369.14 ns 5.57 ns 5.56 ns 1.00
current_thread scheduler create worker + schedule + recursive schedule 807.07 ns 63.95 ns 62.65 ns 1.02

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 847.60 ns 0.31 ns 0.31 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 902.38 ns 0.31 ns 0.31 ns 1.00
immediate_just+flat_map(immediate_just(v*2))+subscribe 2334.89 ns 95.77 ns 96.07 ns 1.00
immediate_just+buffer(2)+subscribe 1576.56 ns 14.20 ns 14.66 ns 0.97
immediate_just+window(2)+subscribe + subscsribe inner 2405.61 ns 719.27 ns 710.42 ns 1.01

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 817.57 ns - - 0.00
immediate_just+take_while(true)+subscribe 819.00 ns 0.31 ns 0.31 ns 1.00

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 1974.39 ns 0.31 ns 0.31 ns 1.00

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 3373.22 ns 113.89 ns 113.86 ns 1.00
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3626.00 ns 107.66 ns 107.69 ns 1.00
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 87.39 ns 86.99 ns 1.00
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 3490.86 ns 471.75 ns 519.85 ns 0.91

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 34.50 ns 23.20 ns 23.82 ns 0.97

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1405.89 ns 14.82 ns 14.82 ns 1.00
basic sample with immediate scheduler 1415.89 ns 5.55 ns 5.56 ns 1.00

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 914.58 ns 0.31 ns 0.31 ns 1.00

ci-macos

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 1102.09 ns 3.41 ns 3.08 ns 1.11
Subscribe empty callbacks to empty observable via pipe operator 1072.20 ns 3.40 ns 3.11 ns 1.09

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 2276.79 ns 0.43 ns 0.24 ns 1.83
from array of 1 - create + subscribe + current_thread 2886.98 ns 8.90 ns 189.49 ns 0.05
concat_as_source of just(1 immediate) create + subscribe 6737.16 ns 301.89 ns 253.49 ns 1.19
defer from array of 1 - defer + create + subscribe + immediate 2384.93 ns 0.28 ns 0.23 ns 1.20
interval - interval + take(3) + subscribe + immediate 6232.34 ns 91.50 ns 117.26 ns 0.78
interval - interval + take(3) + subscribe + current_thread 7659.10 ns 60.42 ns 112.35 ns 0.54

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 3512.43 ns 0.28 ns 0.23 ns 1.19
immediate_just+filter(true)+subscribe 2574.81 ns 0.28 ns 0.23 ns 1.20
immediate_just(1,2)+skip(1)+subscribe 3301.99 ns 0.28 ns 0.23 ns 1.19
immediate_just(1,1,2)+distinct_until_changed()+subscribe 2501.91 ns 0.56 ns 0.47 ns 1.20
immediate_just(1,2)+first()+subscribe 3865.86 ns 0.28 ns 0.23 ns 1.20
immediate_just(1,2)+last()+subscribe 2929.91 ns 0.28 ns 0.23 ns 1.20
immediate_just+take_last(1)+subscribe 3636.88 ns 73.27 ns 70.63 ns 1.04

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 994.67 ns 3.93 ns 2.58 ns 1.52
current_thread scheduler create worker + schedule 1315.01 ns 14.05 ns 35.96 ns 0.39
current_thread scheduler create worker + schedule + recursive schedule 2305.87 ns 162.27 ns 213.29 ns 0.76

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 2543.62 ns 0.28 ns 0.23 ns 1.23
immediate_just+scan(10, std::plus)+subscribe 2809.24 ns 0.56 ns 0.46 ns 1.22
immediate_just+flat_map(immediate_just(v*2))+subscribe 6498.25 ns 351.48 ns 333.34 ns 1.05
immediate_just+buffer(2)+subscribe 3054.01 ns 74.51 ns 69.57 ns 1.07
immediate_just+window(2)+subscribe + subscsribe inner 6478.06 ns 2176.41 ns 1885.10 ns 1.15

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 2550.47 ns - - 0.00
immediate_just+take_while(true)+subscribe 2503.71 ns 0.28 ns 0.23 ns 1.23

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 6011.17 ns 0.28 ns 0.23 ns 1.20

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 9377.12 ns 380.64 ns 359.11 ns 1.06
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 10402.63 ns 420.39 ns 369.99 ns 1.14
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 396.86 ns 389.19 ns 1.02
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 9847.86 ns 1692.96 ns 1466.64 ns 1.15

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 98.61 ns 90.53 ns 84.29 ns 1.07

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 3395.30 ns 44.70 ns 114.39 ns 0.39
basic sample with immediate scheduler 3427.76 ns 6.39 ns 18.06 ns 0.35

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 2964.82 ns 0.28 ns 0.23 ns 1.22

ci-ubuntu-clang

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 273.49 ns 0.88 ns 0.88 ns 1.00
Subscribe empty callbacks to empty observable via pipe operator 267.37 ns 0.88 ns 0.88 ns 1.00

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 566.52 ns 0.34 ns 0.44 ns 0.77
from array of 1 - create + subscribe + current_thread 800.83 ns 5.55 ns 5.56 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 1920.38 ns 71.77 ns 74.04 ns 0.97
defer from array of 1 - defer + create + subscribe + immediate 591.26 ns 0.31 ns 0.31 ns 1.00
interval - interval + take(3) + subscribe + immediate 1550.55 ns 57.07 ns 54.84 ns 1.04
interval - interval + take(3) + subscribe + current_thread 2149.30 ns 30.86 ns 30.86 ns 1.00

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 950.48 ns 0.31 ns 0.31 ns 1.00
immediate_just+filter(true)+subscribe 660.11 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 845.69 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 726.04 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+first()+subscribe 1079.16 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+last()+subscribe 773.94 ns 0.31 ns 0.31 ns 1.00
immediate_just+take_last(1)+subscribe 994.96 ns 0.31 ns 0.31 ns 1.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 195.44 ns 0.88 ns 0.88 ns 1.00
current_thread scheduler create worker + schedule 309.61 ns 5.56 ns 5.57 ns 1.00
current_thread scheduler create worker + schedule + recursive schedule 640.05 ns 57.50 ns 59.12 ns 0.97

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 659.35 ns 0.31 ns 0.31 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 751.89 ns 0.31 ns 0.31 ns 1.02
immediate_just+flat_map(immediate_just(v*2))+subscribe 1839.68 ns 78.81 ns 80.09 ns 0.98
immediate_just+buffer(2)+subscribe 1419.31 ns 13.89 ns 14.51 ns 0.96
immediate_just+window(2)+subscribe + subscsribe inner 2146.03 ns 622.97 ns 595.15 ns 1.05

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 649.27 ns - - 0.00
immediate_just+take_while(true)+subscribe 677.61 ns 0.31 ns 0.31 ns 1.00

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 1631.21 ns 0.31 ns 0.31 ns 1.00

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 2494.01 ns 85.15 ns 85.60 ns 0.99
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3007.41 ns 92.80 ns 95.20 ns 0.97
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 79.02 ns 80.87 ns 0.98
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 2648.51 ns 553.41 ns 546.27 ns 1.01

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 26.19 ns 24.35 ns 24.37 ns 1.00

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1074.10 ns 13.58 ns 13.59 ns 1.00
basic sample with immediate scheduler 1058.64 ns 6.17 ns 6.17 ns 1.00

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 771.52 ns 0.31 ns 0.31 ns 1.00

ci-windows

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 571.22 ns 2.47 ns 3.09 ns 0.80
Subscribe empty callbacks to empty observable via pipe operator 589.08 ns 2.47 ns 3.09 ns 0.80

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 1163.40 ns 4.93 ns 4.93 ns 1.00
from array of 1 - create + subscribe + current_thread 1431.94 ns 19.74 ns 20.38 ns 0.97
concat_as_source of just(1 immediate) create + subscribe 4700.41 ns 154.24 ns 155.39 ns 0.99
defer from array of 1 - defer + create + subscribe + immediate 1209.99 ns 4.93 ns 4.93 ns 1.00
interval - interval + take(3) + subscribe + immediate 3117.49 ns 129.58 ns 130.66 ns 0.99
interval - interval + take(3) + subscribe + current_thread 3488.18 ns 59.98 ns 60.45 ns 0.99

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1844.53 ns 12.83 ns 12.88 ns 1.00
immediate_just+filter(true)+subscribe 1334.29 ns 12.33 ns 12.32 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 1770.52 ns 13.05 ns 13.21 ns 0.99
immediate_just(1,1,2)+distinct_until_changed()+subscribe 1400.70 ns 16.67 ns 15.94 ns 1.05
immediate_just(1,2)+first()+subscribe 2429.60 ns 12.65 ns 12.99 ns 0.97
immediate_just(1,2)+last()+subscribe 1498.39 ns 14.12 ns 14.13 ns 1.00
immediate_just+take_last(1)+subscribe 2070.39 ns 58.86 ns 58.95 ns 1.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 491.89 ns 4.94 ns 4.94 ns 1.00
current_thread scheduler create worker + schedule 674.21 ns 16.04 ns 16.97 ns 0.95
current_thread scheduler create worker + schedule + recursive schedule 1091.27 ns 107.02 ns 107.30 ns 1.00

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 1340.98 ns 12.33 ns 12.34 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 1444.19 ns 21.63 ns 21.27 ns 1.02
immediate_just+flat_map(immediate_just(v*2))+subscribe 3541.08 ns 200.13 ns 200.80 ns 1.00
immediate_just+buffer(2)+subscribe 2642.68 ns 61.66 ns 61.59 ns 1.00
immediate_just+window(2)+subscribe + subscsribe inner 4142.45 ns 1093.25 ns 1088.10 ns 1.00

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 1597.99 ns 11.45 ns 11.44 ns 1.00
immediate_just+take_while(true)+subscribe 1341.94 ns 12.33 ns 12.33 ns 1.00

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 3511.49 ns 8.02 ns 7.71 ns 1.04

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 5313.02 ns 240.28 ns 244.65 ns 0.98
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 6466.10 ns 210.89 ns 211.86 ns 1.00
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 218.30 ns 217.96 ns 1.00
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 6240.00 ns 727.01 ns 740.87 ns 0.98

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 37.84 ns 36.10 ns 36.10 ns 1.00

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1885.59 ns 59.88 ns 60.54 ns 0.99
basic sample with immediate scheduler 1890.30 ns 35.17 ns 35.17 ns 1.00

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 1793.17 ns 19.98 ns 20.03 ns 1.00

Please sign in to comment.