Skip to content

Commit

Permalink
Qt example (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
victimsnino authored Nov 23, 2022
1 parent f399044 commit 708f1f9
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ include(cmake/prelude.cmake)

project(
ReactivePlusPlus
VERSION 0.1.4
VERSION 0.2.0
DESCRIPTION "ReactivePlusPlus is library for building asynchronous event-driven streams of data with help of sequences of primitive operators in the declarative form"
HOMEPAGE_URL "https://github.com/victimsnino/ReactivePlusPlus"
LANGUAGES CXX
Expand Down
1 change: 1 addition & 0 deletions src/examples/rppqt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add_subdirectory(interactive_window)
add_subdirectory(doxygen)
add_subdirectory(multi_threaded)
9 changes: 9 additions & 0 deletions src/examples/rppqt/multi_threaded/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SET(TARGET multi_threaded)
add_executable(${TARGET}
${TARGET}.cpp
)

target_link_libraries(${TARGET} PRIVATE rppqt ${RPP_QT_TARGET}::Widgets)
set_target_properties(${TARGET} PROPERTIES FOLDER Examples/rppqt)

rpp_add_qt_support_to_executable(${TARGET})
71 changes: 71 additions & 0 deletions src/examples/rppqt/multi_threaded/multi_threaded.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <rpp/rpp.hpp>
#include <rppqt/rppqt.hpp>

#include <iostream>

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

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

QLabel label{};
QPushButton button{"CLick me"};
vbox.addWidget(&label);
vbox.addWidget(&button);
QMainWindow window{};

window.setCentralWidget(new QWidget);
window.centralWidget()->setLayout(&vbox);

window.show();

rpp::source::interval(std::chrono::seconds{1})
.tap([](const auto&)
{
std::cout << "Interval from thread: " << std::this_thread::get_id() << std::endl;
})
.combine_latest([](size_t index, size_t amount_of_clicks)
{
return QString("Seconds since start: %1 Clicks since start: %2").arg(index).arg(amount_of_clicks);
},
rppqt::source::from_signal(button, &QPushButton::pressed).scan(size_t{},
[](size_t seed, const auto&)
{
return seed + 1;
})
.tap([](const auto&)
{
std::cout << "Click from thread: " <<
std::this_thread::get_id() << std::endl;
})
.start_with(size_t{0}))
.subscribe_on(rpp::schedulers::new_thread{})
.observe_on(rppqt::schedulers::main_thread_scheduler{})
.subscribe([&](const QString& text)
{
std::cout << "Text updated from thread: " << std::this_thread::get_id() << std::endl;
label.setText(text);
});

std::cout << "Application thread: " << std::this_thread::get_id() << std::endl;

// There we have application's thread, "new_thread" where observable subscribed and interval events happened.
// But we need to update GUI's objects in main thread, so, we forces observable to emit items to subscribe in QT's main thread
// Example of output:
/*
Application thread: 19748 <----- main thread
Interval from thread: 30604 <----- interval happens from another thread
Text updated from thread: 19748 <----- but update then transfered to main thread
Click from thread: 19748 <----- click happens from main thread due to QT logic
Text updated from thread: 19748 <----- and update happens in main thread
Interval from thread: 30604
Text updated from thread: 19748
*/
return app.exec();
}
2 changes: 1 addition & 1 deletion src/rppqt/rppqt/schedulers/main_thread_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class main_thread_scheduler final : public rpp::schedulers::details::scheduler_t
throw utils::no_active_qapplication{
"Pointer to application is null. Create QApplication before using main_thread_scheduler!"};

const auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(now() - time_point).count();
const auto duration = std::max(std::chrono::milliseconds{0}, std::chrono::duration_cast<std::chrono::milliseconds>(time_point - now()));
QTimer::singleShot(duration, application, std::move(fn));
}

Expand Down

1 comment on commit 708f1f9

@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-clang

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 0.34ns 0.334726 1.00 0.34ns
Dynamic observable construction 29.19ns 29.2199 1.00 24.97ns
Specific observable construction + as_dynamic 29.16ns 29.2228 1.00 24.88ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 89.10ns 88.9326 1.00 288.60ns
Specific observable lift dynamic observer 111.83ns 112.589 0.99 306.05ns
Dynamic observable lift specific observer 169.85ns 169.591 1.00 360.60ns
Dynamic observable lift dynamic observer 174.87ns 175.458 1.00 322.56ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 58.08ns 58.0976 1.00 287.13ns
Specific observable subscribe dynamic observer 71.33ns 71.786 0.99 295.02ns
Dynamic observable subscribe specific observer 126.37ns 124.254 1.02 329.45ns
Dynamic observable subscribe dynamic observer 121.59ns 121.69 1.00 313.75ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 58.02ns 58.0997 1.00 286.88ns
Dynamic observable subscribe lambda 124.10ns 124.213 1.00 323.65ns
Specific observable subscribe lambda without subscription 58.04ns 58.297 1.00 287.65ns
Dynamic observable subscribe lambda without subscription 124.77ns 124.528 1.00 328.10ns
Specific observable subscribe specific subscriber 27.79ns 27.805 1.00 223.80ns
Dynamic observable subscribe specific subscriber 88.91ns 88.6075 1.00 269.00ns
Specific observable subscribe dynamic observer 27.82ns 27.7977 1.00 237.34ns
Dynamic observable subscribe dynamic observer 75.33ns 75.4417 1.00 258.01ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.34ns 0.335421 1.00 0.33ns
Dynamic observer construction 29.17ns 31.9974 0.91 21.83ns
Specific observer construction + as_dynamic 29.20ns 29.1369 1.00 21.65ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.67ns 0.669513 1.00 0.67ns
Dynamic observer OnNext 2.01ns 2.01137 1.00 2.35ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 34.82ns 34.8622 1.00 65.12ns
Make copy of subscriber 16.74ns 16.715 1.00 5.62ns
Transform subsriber to dynamic 43.52ns 43.5005 1.00 27.32ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 34.80ns 34.8653 1.00 53.05ns
composite_subscription add 49.27ns 49.2647 1.00 93.06ns
composite_subscription unsubscribe 43.40ns 43.4572 1.00 23.43ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 258.79ns 244.796 1.06 1838.44ns
sending of values from observable via buffer to subscriber 5.38ns 5.36481 1.00 27.61ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 254.68ns 255.371 1.00 499.28ns
long stateful chain creation + subscribe 374.14ns 374.605 1.00 1499.73ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 866.46ns 866.397 1.00 908.33ns
sending of values from observable via combine_latest to subscriber 27.49ns 27.4631 1.00 1.75ns

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 1869.91ns 1855.52 1.01 3299.75ns
concat_with 2175.53ns 2158.38 1.01 3751.39ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 110.72ns 110.538 1.00 246.85ns
sending of values from observable via distinct_until_changed to subscriber 2.68ns 2.68834 1.00 2.34ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 123.72ns 123.787 1.00 575.44ns
sending of values from observable via first to subscriber 0.67ns 0.66943 1.01 0.67ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 61.77ns 61.6889 1.00 618.13ns
error 111.71ns 111.681 1.00 743.86ns
never 28.64ns 28.7588 1.00 249.54ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 77.71ns 78.2974 0.99 652.38ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 1.34ns 1.34302 1.00 112.63ns
re-schedule 10 times 11.46ns 11.4588 1.00 145.67ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 62.71ns 62.5925 1.00 627.76ns
just send variadic 95.17ns 94.7294 1.00 738.94ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 165.77ns 166.432 1.00 352.23ns
sending of values from observable via last to subscriber 2.10ns 2.10663 1.00 1.67ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 68.58ns 68.525 1.00 240.96ns
sending of values from observable via map to subscriber 1.34ns 1.34072 1.00 1.51ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 1806.97ns 1811.31 1.00 3325.75ns
merge_with 2119.46ns 2108.66 1.01 3544.72ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 427.56ns 426.901 1.00 2632.29ns
sending of values from observable via observe_on to subscriber 61.69ns 61.2922 1.01 200.27ns

on_error_resume_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_error_resume_next construction from observable via dot + subscribe 419.51ns 419.541 1.00 1029.96ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 24.11ns 24.1083 1.00 10.70ns
on_error 0.67ns 0.672848 1.00 19.18ns
on_completed 0.67ns 0.674723 1.00 0.67ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 188.77ns 189.072 1.00 180.02ns
get_observable 26.45ns 26.4044 1.00 50.37ns
get_subscriber 60.46ns 60.5939 1.00 13.15ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 3913.56ns 3921.16 1.00 3028.68ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 100.04ns 100.209 1.00 294.04ns
sending of values from observable via scan to subscriber 2.01ns 2.00963 1.00 2.02ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 2.02ns 2.01143 1.00 .
mutex lock increment 18.12ns 18.129 1.00 .
spin-lock increment 9.04ns 9.21068 0.98 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 98.54ns 98.6103 1.00 483.55ns
sending of values from observable via skip to subscriber 2.34ns 2.34051 1.00 1.78ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 2226.03ns 2202.88 1.01 2798.37ns
sending of values from observable via switch_on_next to subscriber 572.48ns 570.666 1.00 644.63ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 170.02ns 169.238 1.00 489.51ns
sending of values from observable via take to subscriber 2.34ns 2.34661 1.00 3.36ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 209.71ns 210.156 1.00 521.85ns
sending of values from observable via take_last to subscriber 2.70ns 2.69872 1.00 3.82ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 1031.08ns 1033.21 1.00 1208.35ns
sending of values from observable via take_until to subscriber 9.02ns 9.0655 0.99 1.84ns

timeout

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
timeout construction from observable via dot + subscribe with run_loop 873.07ns 879.795 0.99 21779.30ns
sending of values from observable via timeout to subscriber with unreachable timeout interval with run_loop 55.86ns 55.8699 1.00 19144.20ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 12.04ns 11.4241 1.05 160.74ns
re-schedule 10 times 32.60ns 32.3297 1.01 188.13ns
recursively schedule 10 times 1457.07ns 1383.93 1.05 8142.52ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 2032.96ns 2003.51 1.01 3151.44ns
sending of values from observable via window to subscriber 548.26ns 548.758 1.00 363.59ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 1026.05ns 1025.63 1.00 1135.44ns
sending of values from observable via with_latest_from to subscriber 27.06ns 27.0484 1.00 3.02ns

ci-ubuntu-gcc

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 0.40ns 0.336362 1.20 0.40ns
Dynamic observable construction 28.78ns 31.5061 0.91 22.18ns
Specific observable construction + as_dynamic 28.84ns 31.5068 0.92 21.81ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 95.17ns 97.6337 0.97 354.60ns
Specific observable lift dynamic observer 129.95ns 126.671 1.03 360.27ns
Dynamic observable lift specific observer 189.30ns 181.287 1.04 425.78ns
Dynamic observable lift dynamic observer 206.42ns 193.421 1.07 378.35ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 60.04ns 60.7882 0.99 355.57ns
Specific observable subscribe dynamic observer 76.74ns 77.2448 0.99 354.29ns
Dynamic observable subscribe specific observer 129.23ns 130.652 0.99 400.18ns
Dynamic observable subscribe dynamic observer 134.16ns 127.491 1.05 367.12ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 60.58ns 60.9857 0.99 349.04ns
Dynamic observable subscribe lambda 130.43ns 130.564 1.00 379.56ns
Specific observable subscribe lambda without subscription 60.69ns 61.0516 0.99 362.14ns
Dynamic observable subscribe lambda without subscription 131.23ns 130.778 1.00 379.79ns
Specific observable subscribe specific subscriber 27.11ns 30.5089 0.89 274.62ns
Dynamic observable subscribe specific subscriber 97.98ns 96.4521 1.02 318.03ns
Specific observable subscribe dynamic observer 27.00ns 30.4889 0.89 283.50ns
Dynamic observable subscribe dynamic observer 94.28ns 85.0005 1.11 293.73ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.40ns 0.335132 1.20 0.40ns
Dynamic observer construction 29.03ns 31.4443 0.92 18.85ns
Specific observer construction + as_dynamic 28.78ns 31.4179 0.92 19.01ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.43ns 0.336904 1.29 0.43ns
Dynamic observer OnNext 2.01ns 2.0075 1.00 1.61ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 33.85ns 34.7442 0.97 59.96ns
Make copy of subscriber 16.10ns 16.7204 0.96 5.90ns
Transform subsriber to dynamic 47.85ns 44.4698 1.08 21.38ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 33.83ns 34.4443 0.98 57.77ns
composite_subscription add 51.44ns 49.2554 1.04 81.55ns
composite_subscription unsubscribe 44.47ns 41.751 1.07 21.19ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 231.52ns 234.576 0.99 1939.00ns
sending of values from observable via buffer to subscriber 6.20ns 6.38967 0.97 26.25ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 325.17ns 288.304 1.13 700.95ns
long stateful chain creation + subscribe 459.56ns 425.761 1.08 1711.60ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 946.14ns 914.241 1.03 1212.80ns
sending of values from observable via combine_latest to subscriber 33.80ns 28.4688 1.19 1.61ns

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 2020.27ns 1915.51 1.05 3924.63ns
concat_with 2433.23ns 2257.44 1.08 4417.15ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 118.61ns 120.162 0.99 374.65ns
sending of values from observable via distinct_until_changed to subscriber 3.20ns 2.70756 1.18 1.30ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 146.29ns 138.052 1.06 764.41ns
sending of values from observable via first to subscriber 0.80ns 1.34178 0.60 0.80ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 67.79ns 67.3747 1.01 785.51ns
error 116.58ns 118.638 0.98 854.83ns
never 29.05ns 32.3486 0.90 292.86ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 82.28ns 85.9514 0.96 794.55ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 0.81ns 1.34311 0.60 133.58ns
re-schedule 10 times 19.07ns 22.4787 0.85 170.75ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 70.42ns 70.8478 0.99 787.87ns
just send variadic 94.73ns 111.102 0.85 848.12ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 179.32ns 175.942 1.02 456.88ns
sending of values from observable via last to subscriber 1.84ns 2.67643 0.69 2.23ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 83.16ns 83.6244 0.99 349.05ns
sending of values from observable via map to subscriber 0.80ns 0.75455 1.06 1.61ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 1971.93ns 1853.58 1.06 4142.00ns
merge_with 2354.85ns 2203.16 1.07 4567.43ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 485.02ns 468.604 1.04 2705.00ns
sending of values from observable via observe_on to subscriber 72.32ns 64.847 1.12 232.26ns

on_error_resume_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_error_resume_next construction from observable via dot + subscribe 456.14ns 435.795 1.05 1057.03ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 29.35ns 22.4133 1.31 9.64ns
on_error 0.81ns 0.675472 1.20 16.18ns
on_completed 0.81ns 0.673359 1.20 0.81ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 205.57ns 207.64 0.99 151.07ns
get_observable 33.33ns 29.4034 1.13 43.10ns
get_subscriber 63.53ns 57.2197 1.11 23.53ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 4345.00ns 4129.91 1.05 3391.67ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 114.12ns 115.57 0.99 401.45ns
sending of values from observable via scan to subscriber 2.01ns 1.69595 1.18 1.70ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 2.95ns 2.00831 1.47 .
mutex lock increment 22.09ns 18.3545 1.20 .
spin-lock increment 10.45ns 9.0489 1.15 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 115.98ns 114.599 1.01 552.38ns
sending of values from observable via skip to subscriber 3.17ns 2.3572 1.35 2.76ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 2450.83ns 2329.02 1.05 5125.17ns
sending of values from observable via switch_on_next to subscriber 629.49ns 600.145 1.05 1343.09ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 171.66ns 175.06 0.98 615.90ns
sending of values from observable via take to subscriber 4.47ns 3.50045 1.28 3.22ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 213.56ns 206.107 1.04 680.57ns
sending of values from observable via take_last to subscriber 3.24ns 3.03971 1.07 6.37ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 1113.67ns 1074.05 1.04 1796.00ns
sending of values from observable via take_until to subscriber 10.44ns 10.7284 0.97 2.01ns

timeout

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
timeout construction from observable via dot + subscribe with run_loop 931.94ns 940.654 0.99 13602.90ns
sending of values from observable via timeout to subscriber with unreachable timeout interval with run_loop 61.97ns 58.1919 1.07 15783.40ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 20.26ns 23.0693 0.88 190.01ns
re-schedule 10 times 42.99ns 51.122 0.84 214.08ns
recursively schedule 10 times 1407.57ns 1448.58 0.97 7940.20ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 2220.79ns 2124.54 1.05 3409.67ns
sending of values from observable via window to subscriber 605.31ns 590.73 1.02 412.23ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 1107.21ns 1087.69 1.02 1588.53ns
sending of values from observable via with_latest_from to subscriber 31.71ns 26.7767 1.18 3.64ns

ci-windows

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 1.50ns 1.33519 1.13 0.67ns
Dynamic observable construction 81.56ns 72.1505 1.13 122.47ns
Specific observable construction + as_dynamic 93.61ns 73.4365 1.27 122.55ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 144.51ns 127.327 1.13 1252.22ns
Specific observable lift dynamic observer 179.20ns 157.971 1.13 1289.18ns
Dynamic observable lift specific observer 289.00ns 253.918 1.14 1468.90ns
Dynamic observable lift dynamic observer 236.58ns 236.794 1.00 1337.62ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 110.20ns 97.3077 1.13 1237.63ns
Specific observable subscribe dynamic observer 130.51ns 130.735 1.00 1269.04ns
Dynamic observable subscribe specific observer 231.00ns 230.4 1.00 1396.05ns
Dynamic observable subscribe dynamic observer 179.42ns 157.385 1.14 1280.86ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 111.84ns 111.837 1.00 1203.77ns
Dynamic observable subscribe lambda 230.29ns 228.698 1.01 1400.67ns
Specific observable subscribe lambda without subscription 111.09ns 97.9037 1.13 1215.62ns
Dynamic observable subscribe lambda without subscription 242.35ns 228.667 1.06 1387.62ns
Specific observable subscribe specific subscriber 30.50ns 26.9129 1.13 860.76ns
Dynamic observable subscribe specific subscriber 147.02ns 150.356 0.98 1044.33ns
Specific observable subscribe dynamic observer 30.49ns 30.4672 1.00 893.50ns
Dynamic observable subscribe dynamic observer 79.64ns 69.7295 1.14 928.58ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 1.51ns 1.50409 1.00 1.50ns
Dynamic observer construction 83.19ns 83.0805 1.00 113.76ns
Specific observer construction + as_dynamic 84.14ns 95.7867 0.88 113.73ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.67ns 0.573022 1.17 0.67ns
Dynamic observer OnNext 2.01ns 2.0076 1.00 2.02ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 83.78ns 74.0542 1.13 353.85ns
Make copy of subscriber 16.71ns 16.7141 1.00 31.93ns
Transform subsriber to dynamic 97.48ns 86.1312 1.13 153.22ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 84.27ns 74.2962 1.13 348.43ns
composite_subscription add 68.77ns 63.4774 1.08 160.97ns
composite_subscription unsubscribe 62.82ns 58.4007 1.08 132.93ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 352.94ns 351.161 1.01 4478.57ns
sending of values from observable via buffer to subscriber 7.24ns 6.25282 1.16 92.15ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 270.31ns 236.932 1.14 1778.73ns
long stateful chain creation + subscribe 656.92ns 581.59 1.13 3219.25ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 1617.67ns 1605.5 1.01 3467.89ns
sending of values from observable via combine_latest to subscriber 47.21ns 47.1516 1.00 4.50ns

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 2791.22ns 2426.78 1.15 11565.00ns
concat_with 3405.00ns 4105.88 0.83 11737.70ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 187.49ns 184.626 1.02 1047.37ns
sending of values from observable via distinct_until_changed to subscriber 4.58ns 4.4372 1.03 3.95ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 128.79ns 132.223 0.97 2634.36ns
sending of values from observable via first to subscriber 2.35ns 2.34791 1.00 1.75ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 64.11ns 63.1771 1.01 2414.45ns
error 112.90ns 118.114 0.96 2509.27ns
never 30.99ns 31.815 0.97 950.75ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 136.69ns 135.0 1.01 2499.18ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 1.96ns 1.54062 1.27 408.75ns
re-schedule 10 times 97.75ns 86.446 1.13 436.09ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 66.09ns 58.184 1.14 2426.55ns
just send variadic 103.12ns 103.128 1.00 2488.45ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 232.15ns 197.68 1.17 1451.42ns
sending of values from observable via last to subscriber 3.27ns 3.19703 1.02 3.32ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 87.84ns 88.4691 0.99 1021.14ns
sending of values from observable via map to subscriber 3.52ns 3.51213 1.00 6.95ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 170464.00ns 2350.6 72.52 11003.30ns
merge_with 3343.00ns 3312.67 1.01 11728.70ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 646.85ns 555.194 1.17 5841.80ns
sending of values from observable via observe_on to subscriber 64.74ns 52.9506 1.22 817.62ns

on_error_resume_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_error_resume_next construction from observable via dot + subscribe 635.79ns 558.243 1.14 1827.57ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 19.84ns 17.5543 1.13 32.76ns
on_error 2.82ns 2.44627 1.15 18.36ns
on_completed 3.04ns 2.68064 1.13 1.36ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 385.31ns 315.726 1.22 603.47ns
get_observable 30.11ns 23.0744 1.30 161.72ns
get_subscriber 50.17ns 44.7119 1.12 92.20ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 6072.00ns 5373.25 1.13 11968.30ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 183.67ns 182.878 1.00 1272.05ns
sending of values from observable via scan to subscriber 5.37ns 4.75422 1.13 9.51ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 1.88ns 2.16717 0.87 .
mutex lock increment 26.20ns 25.7656 1.02 .
spin-lock increment 9.04ns 7.97412 1.13 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 287.80ns 176.71 1.63 1558.94ns
sending of values from observable via skip to subscriber 3.39ns 2.96701 1.14 4.24ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 3495.12ns 3124.57 1.12 12086.30ns
sending of values from observable via switch_on_next to subscriber 854.67ns 762.138 1.12 3384.50ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 407.75ns 197.022 2.07 2170.77ns
sending of values from observable via take to subscriber 5.88ns 5.19453 1.13 6.13ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 323.14ns 322.747 1.00 2439.36ns
sending of values from observable via take_last to subscriber 4.29ns 5.03471 0.85 20.81ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 1648.00ns 1580.18 1.04 5232.17ns
sending of values from observable via take_until to subscriber 11.53ns 11.6128 0.99 5.39ns

timeout

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
timeout construction from observable via dot + subscribe with run_loop 1370.67ns 1181.94 1.16 5803.00ns
sending of values from observable via timeout to subscriber with unreachable timeout interval with run_loop 55.12ns 49.3492 1.12 1356.94ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 19.32ns 19.0977 1.01 622.11ns
re-schedule 10 times 122.25ns 107.765 1.13 648.88ns
recursively schedule 10 times 2636.50ns 2324.6 1.13 18993.00ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 2922.22ns 2932.89 1.00 9690.00ns
sending of values from observable via window to subscriber 831.50ns 893.5 0.93 1634.00ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 2200.92ns 1754.0 1.25 3829.43ns
sending of values from observable via with_latest_from to subscriber 38.12ns 33.605 1.13 7.55ns

Please sign in to comment.