Skip to content

Commit

Permalink
Fix issue with execution after unsubscribe (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
victimsnino authored Nov 20, 2022
1 parent fc3b44b commit ae351ec
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rpp/rpp/schedulers/details/worker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class schedulable_wrapper

void operator()()
{
if (auto duration = m_fn())
if (!m_strategy.is_subscribed())
return;

if (const auto duration = m_fn())
{
m_time_point = std::max(m_strategy.now(), m_time_point + duration.value());

Expand Down
9 changes: 9 additions & 0 deletions src/rpp/rpp/schedulers/new_thread_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class new_thread final : public details::scheduler_tag
m_state = shared;
}

bool is_subscribed() const
{
if (const auto locked = m_state.lock())
return locked->is_subscribed();
return false;
}

void defer_at(time_point time_point, constraint::schedulable_fn auto&& fn) const
{
defer_at(time_point, new_thread_schedulable{*this, time_point, std::forward<decltype(fn)>(fn)});
Expand All @@ -65,6 +72,8 @@ class new_thread final : public details::scheduler_tag
state(const state&) = delete;
state(state&&) noexcept = delete;

bool is_subscribed() const { return m_sub->is_subscribed(); }

void defer_at(time_point time_point, new_thread_schedulable&& fn)
{
if (m_sub->is_subscribed())
Expand Down
5 changes: 5 additions & 0 deletions src/rpp/rpp/schedulers/run_loop_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class run_loop final : public details::scheduler_tag
, m_sub{sub}
{}

bool is_subscribed() const
{
return m_sub.is_subscribed();
}

void defer_at(time_point time_point, constraint::schedulable_fn auto&& fn) const
{
defer_at(time_point, run_loop_schedulable{*this, time_point, std::forward<decltype(fn)>(fn)});
Expand Down
5 changes: 5 additions & 0 deletions src/rpp/rpp/schedulers/trampoline_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class trampoline final : public details::scheduler_tag
explicit worker_strategy(const rpp::composite_subscription& subscription)
: m_sub{ subscription } {}

bool is_subscribed() const
{
return m_sub.is_subscribed();
}

void defer_at(time_point time_point, constraint::schedulable_fn auto&& fn) const
{
if (!m_sub.is_subscribed())
Expand Down

1 comment on commit ae351ec

@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.335048 1.00 0.34ns
Dynamic observable construction 29.19ns 29.1444 1.00 24.25ns
Specific observable construction + as_dynamic 29.19ns 29.1059 1.00 24.14ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 88.72ns 88.9114 1.00 291.64ns
Specific observable lift dynamic observer 112.03ns 111.572 1.00 308.73ns
Dynamic observable lift specific observer 170.12ns 170.776 1.00 336.09ns
Dynamic observable lift dynamic observer 175.34ns 177.609 0.99 340.74ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 58.00ns 57.9403 1.00 293.76ns
Specific observable subscribe dynamic observer 71.38ns 71.5598 1.00 300.31ns
Dynamic observable subscribe specific observer 125.40ns 125.031 1.00 330.87ns
Dynamic observable subscribe dynamic observer 121.32ns 123.881 0.98 322.29ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 58.02ns 58.0255 1.00 294.16ns
Dynamic observable subscribe lambda 124.20ns 124.054 1.00 331.12ns
Specific observable subscribe lambda without subscription 58.06ns 58.0292 1.00 292.68ns
Dynamic observable subscribe lambda without subscription 124.73ns 124.201 1.00 333.05ns
Specific observable subscribe specific subscriber 27.84ns 27.8032 1.00 230.38ns
Dynamic observable subscribe specific subscriber 88.94ns 88.6379 1.00 272.76ns
Specific observable subscribe dynamic observer 27.80ns 27.7769 1.00 241.58ns
Dynamic observable subscribe dynamic observer 75.38ns 77.328 0.97 263.48ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.34ns 0.334844 1.00 0.34ns
Dynamic observer construction 29.21ns 29.133 1.00 21.79ns
Specific observer construction + as_dynamic 29.21ns 29.1611 1.00 21.50ns

OnNext

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

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 34.85ns 34.9146 1.00 64.78ns
Make copy of subscriber 16.74ns 16.742 1.00 4.70ns
Transform subsriber to dynamic 43.46ns 43.5518 1.00 25.64ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 34.81ns 34.8133 1.00 51.98ns
composite_subscription add 49.29ns 47.4828 1.04 90.53ns
composite_subscription unsubscribe 43.35ns 43.4577 1.00 23.41ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 243.19ns 246.506 0.99 1819.62ns
sending of values from observable via buffer to subscriber 5.36ns 5.3531 1.00 28.19ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 254.05ns 254.713 1.00 503.59ns
long stateful chain creation + subscribe 373.43ns 376.337 0.99 1392.53ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 863.41ns 866.083 1.00 855.60ns
sending of values from observable via combine_latest to subscriber 27.46ns 27.4375 1.00 1.75ns

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 1875.38ns 1867.4 1.00 3415.57ns
concat_with 2157.54ns 2162.12 1.00 3770.29ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 110.61ns 110.714 1.00 248.91ns
sending of values from observable via distinct_until_changed to subscriber 2.68ns 2.68163 1.00 2.35ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 123.34ns 124.274 0.99 579.39ns
sending of values from observable via first to subscriber 0.67ns 0.67089 1.00 0.67ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 61.47ns 61.8223 0.99 624.28ns
error 111.52ns 112.157 0.99 753.44ns
never 28.63ns 28.7012 1.00 258.36ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 78.10ns 79.7985 0.98 659.67ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 1.34ns 1.34103 1.00 112.74ns
re-schedule 10 times 11.45ns 11.4653 1.00 144.16ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 62.90ns 65.0726 0.97 636.10ns
just send variadic 94.73ns 94.8347 1.00 749.14ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 165.61ns 168.999 0.98 360.00ns
sending of values from observable via last to subscriber 2.11ns 2.12903 0.99 1.68ns

map

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

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 1799.27ns 1818.16 0.99 3272.26ns
merge_with 2101.44ns 2106.38 1.00 3585.07ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 425.25ns 426.379 1.00 2583.85ns
sending of values from observable via observe_on to subscriber 61.23ns 61.3564 1.00 199.28ns

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 418.37ns 421.93 0.99 939.07ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 24.06ns 24.1378 1.00 10.72ns
on_error 0.67ns 0.672872 1.00 19.18ns
on_completed 0.67ns 0.673547 1.00 0.67ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 199.60ns 195.625 1.02 186.37ns
get_observable 26.40ns 26.43 1.00 50.37ns
get_subscriber 60.60ns 60.4985 1.00 13.82ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 3906.45ns 3883.35 1.01 3049.76ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 100.18ns 100.386 1.00 298.02ns
sending of values from observable via scan to subscriber 2.01ns 2.00717 1.00 2.01ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 2.02ns 2.02019 1.00 .
mutex lock increment 18.07ns 18.0536 1.00 .
spin-lock increment 9.05ns 15.7092 0.58 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 98.32ns 98.8826 0.99 465.75ns
sending of values from observable via skip to subscriber 2.35ns 2.34374 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 2212.04ns 2194.77 1.01 2823.69ns
sending of values from observable via switch_on_next to subscriber 570.88ns 568.996 1.00 645.11ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 168.69ns 169.672 0.99 491.54ns
sending of values from observable via take to subscriber 2.34ns 2.34731 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 208.04ns 210.326 0.99 529.79ns
sending of values from observable via take_last to subscriber 2.70ns 2.69318 1.00 3.81ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 1024.42ns 1029.9 0.99 1167.95ns
sending of values from observable via take_until to subscriber 9.81ns 9.03606 1.09 1.85ns

timeout

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
timeout construction from observable via dot + subscribe with run_loop 866.91ns 868.027 1.00 15327.80ns
sending of values from observable via timeout to subscriber with unreachable timeout interval with run_loop 55.85ns 55.8089 1.00 13992.60ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 11.38ns 12.0126 0.95 162.13ns
re-schedule 10 times 32.42ns 32.5272 1.00 189.40ns
recursively schedule 10 times 1397.57ns 1450.72 0.96 7871.76ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 2008.29ns 1991.93 1.01 3152.26ns
sending of values from observable via window to subscriber 545.77ns 541.102 1.01 365.68ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 1023.29ns 1016.06 1.01 1108.57ns
sending of values from observable via with_latest_from to subscriber 27.02ns 27.0523 1.00 3.01ns

ci-ubuntu-gcc

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 0.40ns 0.402061 1.00 0.40ns
Dynamic observable construction 29.06ns 37.9303 0.77 22.32ns
Specific observable construction + as_dynamic 29.01ns 37.0661 0.78 21.76ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 95.36ns 117.578 0.81 344.83ns
Specific observable lift dynamic observer 130.65ns 152.217 0.86 370.20ns
Dynamic observable lift specific observer 188.71ns 218.016 0.87 437.76ns
Dynamic observable lift dynamic observer 204.01ns 231.237 0.88 376.67ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 60.20ns 72.5318 0.83 343.99ns
Specific observable subscribe dynamic observer 78.62ns 93.0589 0.84 360.97ns
Dynamic observable subscribe specific observer 128.99ns 156.993 0.82 389.89ns
Dynamic observable subscribe dynamic observer 134.25ns 152.545 0.88 368.26ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 60.45ns 72.1494 0.84 352.15ns
Dynamic observable subscribe lambda 131.99ns 148.613 0.89 384.46ns
Specific observable subscribe lambda without subscription 60.29ns 73.0114 0.83 362.91ns
Dynamic observable subscribe lambda without subscription 130.57ns 156.697 0.83 389.80ns
Specific observable subscribe specific subscriber 26.57ns 36.8529 0.72 278.31ns
Dynamic observable subscribe specific subscriber 96.44ns 116.294 0.83 321.66ns
Specific observable subscribe dynamic observer 26.66ns 36.5423 0.73 283.91ns
Dynamic observable subscribe dynamic observer 90.20ns 98.4839 0.92 294.17ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.40ns 0.384403 1.05 0.40ns
Dynamic observer construction 28.98ns 37.956 0.76 18.78ns
Specific observer construction + as_dynamic 28.95ns 37.7516 0.77 18.46ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.43ns 0.401868 1.07 0.44ns
Dynamic observer OnNext 2.01ns 2.4148 0.83 1.61ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 33.45ns 41.3798 0.81 59.92ns
Make copy of subscriber 16.10ns 20.2309 0.80 5.96ns
Transform subsriber to dynamic 44.61ns 53.1788 0.84 20.93ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 33.78ns 42.4251 0.80 57.20ns
composite_subscription add 51.71ns 58.6971 0.88 98.17ns
composite_subscription unsubscribe 45.06ns 50.4563 0.89 21.20ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 233.70ns 280.869 0.83 2021.13ns
sending of values from observable via buffer to subscriber 6.78ns 7.25612 0.93 26.45ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 332.75ns 344.712 0.97 686.08ns
long stateful chain creation + subscribe 448.11ns 511.241 0.88 1685.73ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 946.00ns 1110.19 0.85 1218.31ns
sending of values from observable via combine_latest to subscriber 33.74ns 33.9516 0.99 1.61ns

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 2011.13ns 2334.47 0.86 3897.86ns
concat_with 2392.84ns 2616.61 0.91 4367.56ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 119.39ns 144.725 0.82 382.10ns
sending of values from observable via distinct_until_changed to subscriber 3.21ns 3.28053 0.98 1.43ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 148.04ns 166.008 0.89 765.59ns
sending of values from observable via first to subscriber 0.80ns 1.61024 0.50 0.81ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 67.76ns 80.8058 0.84 788.21ns
error 126.42ns 139.18 0.91 846.11ns
never 28.93ns 38.6122 0.75 294.35ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 82.97ns 101.993 0.81 790.21ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 0.80ns 1.61008 0.50 127.57ns
re-schedule 10 times 19.10ns 18.4418 1.04 163.75ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 70.84ns 84.9508 0.83 785.79ns
just send variadic 92.71ns 130.803 0.71 844.80ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 180.89ns 210.997 0.86 457.03ns
sending of values from observable via last to subscriber 1.75ns 2.76658 0.63 1.18ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 79.70ns 98.4825 0.81 349.29ns
sending of values from observable via map to subscriber 0.80ns 0.904771 0.89 1.61ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 1991.99ns 2278.53 0.87 4095.49ns
merge_with 2355.84ns 2722.35 0.87 4691.98ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 482.74ns 567.452 0.85 2724.24ns
sending of values from observable via observe_on to subscriber 72.30ns 83.3275 0.87 231.86ns

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 452.76ns 524.539 0.86 1059.64ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 29.73ns 26.9056 1.10 9.64ns
on_error 0.81ns 0.810696 1.00 16.16ns
on_completed 0.82ns 0.811947 1.00 0.81ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 213.08ns 256.899 0.83 147.00ns
get_observable 30.49ns 35.3883 0.86 42.64ns
get_subscriber 63.48ns 69.0128 0.92 21.60ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 4357.84ns 4901.69 0.89 3449.19ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 115.61ns 138.953 0.83 400.38ns
sending of values from observable via scan to subscriber 2.01ns 2.29802 0.88 2.01ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 2.79ns 2.41269 1.16 .
mutex lock increment 22.51ns 21.7163 1.04 .
spin-lock increment 10.44ns 11.1225 0.94 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 117.17ns 137.152 0.85 550.11ns
sending of values from observable via skip to subscriber 3.16ns 3.19525 0.99 2.73ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 2450.08ns 2800.12 0.87 4404.41ns
sending of values from observable via switch_on_next to subscriber 653.18ns 719.05 0.91 1204.48ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 172.60ns 205.355 0.84 614.37ns
sending of values from observable via take to subscriber 4.08ns 4.20892 0.97 3.22ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 213.84ns 255.194 0.84 681.98ns
sending of values from observable via take_last to subscriber 3.24ns 4.04263 0.80 6.38ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 1123.77ns 1260.05 0.89 1769.52ns
sending of values from observable via take_until to subscriber 10.42ns 10.849 0.96 2.04ns

timeout

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
timeout construction from observable via dot + subscribe with run_loop 938.31ns 1149.81 0.82 13829.30ns
sending of values from observable via timeout to subscriber with unreachable timeout interval with run_loop 61.58ns 72.5084 0.85 17086.30ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 20.83ns 25.3331 0.82 192.71ns
re-schedule 10 times 42.42ns 60.0266 0.71 213.62ns
recursively schedule 10 times 1496.14ns 1740.93 0.86 7934.97ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 2233.53ns 2464.82 0.91 3436.54ns
sending of values from observable via window to subscriber 610.66ns 713.77 0.86 412.42ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 1113.94ns 1311.39 0.85 1596.43ns
sending of values from observable via with_latest_from to subscriber 31.79ns 32.1491 0.99 3.66ns

ci-windows

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 2.06ns 1.50395 1.37 0.80ns
Dynamic observable construction 163.76ns 81.0701 2.02 155.44ns
Specific observable construction + as_dynamic 100.39ns 84.4058 1.19 156.67ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 174.25ns 143.75 1.21 1542.74ns
Specific observable lift dynamic observer 220.97ns 176.778 1.25 1455.26ns
Dynamic observable lift specific observer 363.95ns 284.911 1.28 1866.71ns
Dynamic observable lift dynamic observer 304.33ns 235.404 1.29 1694.42ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 164.51ns 110.708 1.49 1416.00ns
Specific observable subscribe dynamic observer 163.53ns 130.138 1.26 1415.20ns
Dynamic observable subscribe specific observer 272.34ns 230.259 1.18 1946.39ns
Dynamic observable subscribe dynamic observer 210.16ns 177.778 1.18 1461.16ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 138.62ns 111.043 1.25 1634.50ns
Dynamic observable subscribe lambda 310.70ns 230.339 1.35 1545.39ns
Specific observable subscribe lambda without subscription 140.60ns 120.281 1.17 1608.20ns
Dynamic observable subscribe lambda without subscription 329.30ns 230.035 1.43 1596.78ns
Specific observable subscribe specific subscriber 39.00ns 30.4332 1.28 1096.56ns
Dynamic observable subscribe specific subscriber 185.57ns 147.659 1.26 1216.58ns
Specific observable subscribe dynamic observer 37.71ns 33.4446 1.13 1082.33ns
Dynamic observable subscribe dynamic observer 93.16ns 78.6185 1.19 1123.92ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 1.92ns 1.50481 1.28 2.02ns
Dynamic observer construction 104.98ns 113.555 0.92 152.00ns
Specific observer construction + as_dynamic 105.81ns 83.2997 1.27 166.65ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.82ns 0.669171 1.23 0.79ns
Dynamic observer OnNext 2.41ns 2.01932 1.19 2.13ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 105.72ns 84.0429 1.26 468.20ns
Make copy of subscriber 18.99ns 16.7204 1.14 38.67ns
Transform subsriber to dynamic 119.85ns 97.5551 1.23 195.18ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 106.48ns 83.8947 1.27 415.54ns
composite_subscription add 90.49ns 68.6541 1.32 183.20ns
composite_subscription unsubscribe 74.75ns 61.941 1.21 144.41ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 441.90ns 351.8 1.26 5607.17ns
sending of values from observable via buffer to subscriber 8.88ns 7.24804 1.23 124.02ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 319.26ns 269.776 1.18 2095.77ns
long stateful chain creation + subscribe 789.49ns 655.73 1.20 4026.86ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 1984.79ns 1594.62 1.24 3636.43ns
sending of values from observable via combine_latest to subscriber 58.01ns 47.6642 1.22 4.74ns

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 3314.44ns 2732.6 1.21 12621.70ns
concat_with 4787.25ns 3418.75 1.40 15650.00ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 248.99ns 183.619 1.36 1293.52ns
sending of values from observable via distinct_until_changed to subscriber 7.31ns 4.38288 1.67 4.99ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 157.42ns 127.804 1.23 3243.11ns
sending of values from observable via first to subscriber 3.02ns 2.34446 1.29 1.21ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 85.42ns 63.5136 1.34 3220.10ns
error 144.72ns 112.832 1.28 3334.50ns
never 37.46ns 30.8106 1.22 1127.76ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 164.84ns 135.358 1.22 2969.33ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 1.63ns 2.00865 0.81 519.84ns
re-schedule 10 times 135.17ns 97.8077 1.38 541.74ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 83.53ns 65.7518 1.27 3093.80ns
just send variadic 121.52ns 102.619 1.18 3023.00ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 272.76ns 223.07 1.22 1706.73ns
sending of values from observable via last to subscriber 4.21ns 3.63398 1.16 5.87ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 107.26ns 87.6907 1.22 1238.42ns
sending of values from observable via map to subscriber 4.13ns 3.51135 1.18 8.70ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 3187.44ns 2667.7 1.19 14738.30ns
merge_with 4259.86ns 3315.88 1.28 14655.00ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 798.86ns 624.1 1.28 7224.00ns
sending of values from observable via observe_on to subscriber 80.99ns 65.1671 1.24 988.28ns

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 768.68ns 636.59 1.21 2597.82ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 24.47ns 19.9614 1.23 37.51ns
on_error 3.48ns 2.81454 1.24 21.05ns
on_completed 2.99ns 3.0336 0.99 0.79ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 408.51ns 355.548 1.15 802.00ns
get_observable 34.59ns 26.1003 1.33 198.99ns
get_subscriber 65.73ns 50.1732 1.31 113.08ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 8219.00ns 6001.4 1.37 13675.00ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 223.56ns 182.207 1.23 1537.35ns
sending of values from observable via scan to subscriber 8.26ns 5.38541 1.53 10.73ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 3.14ns 1.88627 1.66 .
mutex lock increment 33.31ns 25.7982 1.29 .
spin-lock increment 14.37ns 9.03675 1.59 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 202.11ns 177.083 1.14 1936.71ns
sending of values from observable via skip to subscriber 4.42ns 3.35659 1.32 5.09ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 4272.43ns 3494.5 1.22 15809.50ns
sending of values from observable via switch_on_next to subscriber 1023.66ns 853.258 1.20 3641.25ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 278.31ns 224.03 1.24 2896.36ns
sending of values from observable via take to subscriber 6.00ns 5.94782 1.01 6.97ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 510.16ns 323.239 1.58 3051.00ns
sending of values from observable via take_last to subscriber 4.70ns 4.24898 1.11 25.73ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 1849.27ns 1584.0 1.17 6281.40ns
sending of values from observable via take_until to subscriber 13.94ns 13.2442 1.05 6.33ns

timeout

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
timeout construction from observable via dot + subscribe with run_loop 1639.44ns 1279.29 1.28 6335.00ns
sending of values from observable via timeout to subscriber with unreachable timeout interval with run_loop 68.49ns 55.2905 1.24 1737.71ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 21.90ns 18.7774 1.17 770.10ns
re-schedule 10 times 141.31ns 121.89 1.16 910.11ns
recursively schedule 10 times 3628.22ns 2622.0 1.38 26259.00ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 3432.00ns 2925.89 1.17 12135.30ns
sending of values from observable via window to subscriber 1125.41ns 831.194 1.35 2077.13ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 2644.00ns 1971.08 1.34 4581.40ns
sending of values from observable via with_latest_from to subscriber 43.04ns 38.3612 1.12 10.33ns

Please sign in to comment.