Skip to content

Commit

Permalink
Simplify a bit (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
victimsnino authored Feb 12, 2023
1 parent b71638e commit 8753ba7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 66 deletions.
64 changes: 14 additions & 50 deletions src/rpp/rpp/observers/dynamic_observer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,71 +63,35 @@ std::shared_ptr<dynamic_observer_state_base<T>> make_dynamic_observer_state_from
}

template<constraint::decayed_type T, constraint::decayed_type ...States>
class dynamic_state_observer : public details::typed_observer_tag<T>
class dynamic_state_observer : public state_observer<T, utils::forwarding_on_next_for_pointer,utils::forwarding_on_error_for_pointer, utils::forwarding_on_completed_for_pointer, std::shared_ptr<dynamic_observer_state_base<T>>>
{
using base = state_observer<T, utils::forwarding_on_next_for_pointer,utils::forwarding_on_error_for_pointer, utils::forwarding_on_completed_for_pointer, std::shared_ptr<dynamic_observer_state_base<T>>>;
public:
template<typename ...TStates>
requires (constraint::decayed_same_as<States, TStates> && ...)
dynamic_state_observer(std::invocable<T, States...> auto&& on_next,
std::invocable<std::exception_ptr, States...> auto&& on_error,
std::invocable<States...> auto&& on_completed,
TStates&& ... states)
: m_state{make_dynamic_observer_state_from_fns<T>(std::forward<decltype(on_next)>(on_next),
std::forward<decltype(on_error)>(on_error),
std::forward<decltype(on_completed)>(on_completed),
std::forward<TStates>(states)...)} {}
: base{utils::forwarding_on_next_for_pointer{},
utils::forwarding_on_error_for_pointer{},
utils::forwarding_on_completed_for_pointer{},
make_dynamic_observer_state_from_fns<T>(std::forward<decltype(on_next)>(on_next),
std::forward<decltype(on_error)>(on_error),
std::forward<decltype(on_completed)>(on_completed),
std::forward<TStates>(states)...)} {}

dynamic_state_observer(std::shared_ptr<details::dynamic_observer_state_base<T>> state)
: m_state{ std::move(state) } {}
: base{utils::forwarding_on_next_for_pointer{},
utils::forwarding_on_error_for_pointer{},
utils::forwarding_on_completed_for_pointer{},
std::move(state)} {}


template<constraint::observer_of_type<T> TObserver>
requires (!std::is_same_v<std::decay_t<TObserver>, dynamic_state_observer<T, States...>>)
dynamic_state_observer(TObserver&& obs)
: m_state{details::make_dynamic_observer_state<T, std::decay_t<TObserver>>(std::forward<TObserver>(obs))} {}


/**
* \brief Observable calls this methods to notify observer about new value.
*
* \note obtains value by const-reference to original object.
*/
void on_next(const T& v) const
{
m_state->on_next(v);
}

/**
* \brief Observable calls this methods to notify observer about new value.
*
* \note obtains value by rvalue-reference to original object
*/
void on_next(T&& v) const
{
m_state->on_next(std::move(v));
}

/**
* \brief Observable calls this method to notify observer about some error during generation next data.
* \warning Obtaining this call means no any further on_next or on_completed calls
* \param err details of error
*/
void on_error(const std::exception_ptr& err) const
{
m_state->on_error(err);
}

/**
* \brief Observable calls this method to notify observer about finish of work.
* \warning Obtaining this call means no any further on_next calls
*/
void on_completed() const
{
m_state->on_completed();
}

private:
std::shared_ptr<dynamic_observer_state_base<T>> m_state{};
: dynamic_state_observer{details::make_dynamic_observer_state<T, std::decay_t<TObserver>>(std::forward<TObserver>(obs))} {}
};
} // namespace rpp::details

Expand Down
6 changes: 0 additions & 6 deletions src/rpp/rpp/operators/fwd/subscribe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,5 @@ struct member_overload<Type, SpecificObservable, subscribe_tag>
{
return static_cast<const SpecificObservable*>(this)->subscribe_impl(subscriber);
}

template<constraint::observer_of_type<Type> Obs>
auto subscribe_impl(specific_subscriber<Type, Obs>&& subscriber) const
{
return static_cast<const SpecificObservable*>(this)->subscribe_impl(std::move(subscriber));
}
};
} // namespace rpp::details
14 changes: 4 additions & 10 deletions src/rpp/rpp/sources/from.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ auto extract_iterable_from_packed(const std::shared_ptr<T> & v) -> const auto&
return *v;
}

void iterate(auto&& iterable,
void iterate(const auto& iterable,
const schedulers::constraint::scheduler auto& scheduler,
constraint::subscriber auto&& subscriber)
{
Expand All @@ -58,7 +58,7 @@ void iterate(auto&& iterable,
else
{
auto worker = scheduler.create_worker(subscriber.get_subscription());
worker.schedule([iterable=std::forward<decltype(iterable)>(iterable),
worker.schedule([iterable=iterable,
subscriber=std::forward<decltype(subscriber)>(subscriber),
index = size_t{0}]() mutable-> schedulers::optional_duration
{
Expand Down Expand Up @@ -123,19 +123,13 @@ class iterate_impl
, m_scheduler{scheduler} {}

template<constraint::subscriber TSub>
void operator()(TSub&& subscriber) const &
void operator()(TSub&& subscriber) const
{
details::iterate(m_iterable, m_scheduler, std::forward<TSub>(subscriber));
}

template<constraint::subscriber TSub>
void operator()(TSub&& subscriber) const &&
{
details::iterate(std::move(m_iterable), m_scheduler, std::forward<TSub>(subscriber));
}

private:
mutable PackedIterable m_iterable;
PackedIterable m_iterable;
RPP_NO_UNIQUE_ADDRESS TScheduler m_scheduler;
};
} // namespace rpp::observable::details
Expand Down

1 comment on commit 8753ba7

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

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 0.29ns 0.279113 1.02 0.30ns
Dynamic observable construction 72.42ns 76.6756 0.94 108.39ns
Specific observable construction + as_dynamic 74.87ns 72.1524 1.04 109.80ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 141.14ns 131.917 1.07 1141.95ns
Specific observable lift dynamic observer 155.86ns 163.498 0.95 1310.85ns
Dynamic observable lift specific observer 247.68ns 268.868 0.92 1289.69ns
Dynamic observable lift dynamic observer 209.51ns 212.062 0.99 1199.83ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 121.33ns 134.496 0.90 1111.75ns
Specific observable subscribe dynamic observer 117.74ns 127.316 0.92 1228.02ns
Dynamic observable subscribe specific observer 212.40ns 222.584 0.95 1329.15ns
Dynamic observable subscribe dynamic observer 167.19ns 168.252 0.99 1198.37ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 124.23ns 115.536 1.08 1305.18ns
Dynamic observable subscribe lambda 201.19ns 213.241 0.94 1272.03ns
Specific observable subscribe lambda without subscription 116.18ns 106.175 1.09 1148.53ns
Dynamic observable subscribe lambda without subscription 221.02ns 206.038 1.07 1218.12ns
Specific observable subscribe specific subscriber 58.80ns 30.041 1.96 827.87ns
Dynamic observable subscribe specific subscriber 157.18ns 132.306 1.19 973.84ns
Specific observable subscribe dynamic observer 32.24ns 32.6666 0.99 878.62ns
Dynamic observable subscribe dynamic observer 73.81ns 103.005 0.72 844.42ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.63ns 0.279209 2.25 0.29ns
Dynamic observer construction 84.30ns 90.4257 0.93 106.77ns
Specific observer construction + as_dynamic 80.30ns 74.8932 1.07 108.62ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.95ns 0.786286 1.21 0.87ns
Dynamic observer OnNext 2.20ns 2.14655 1.03 2.59ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 78.00ns 75.1669 1.04 341.60ns
Make copy of subscriber 13.11ns 12.2524 1.07 26.37ns
Transform subsriber to dynamic 95.23ns 82.7585 1.15 130.08ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 73.26ns 70.3482 1.04 294.32ns
composite_subscription add 57.81ns 61.8728 0.93 116.04ns
composite_subscription unsubscribe 85.74ns 70.8025 1.21 83.82ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 1362.93ns 1421.05 0.96 3124.15ns
sending of values from observable via buffer to subscriber 5.97ns 13.0322 0.46 85.97ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 292.40ns 217.548 1.34 1528.56ns
long stateful chain creation + subscribe 1354.62ns 533.042 2.54 2799.99ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 1355.06ns 1379.63 0.98 .
sending of values from observable via combine_latest to subscriber 26.50ns 23.4083 1.13 .

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 4256.13ns 4121.89 1.03 17937.00ns
concat_with 4225.73ns 4122.66 1.03 11403.10ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 155.84ns 151.373 1.03 878.85ns
sending of values from observable via distinct_until_changed to subscriber 2.25ns 2.23588 1.00 1.11ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 191.82ns 193.216 0.99 2185.51ns
sending of values from observable via first to subscriber 0.66ns 0.557867 1.19 0.96ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 63.11ns 117.488 0.54 2339.51ns
error 118.06ns 116.785 1.01 2714.99ns
never 33.10ns 32.1619 1.03 1164.43ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 807.23ns 757.538 1.07 2254.90ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 2.01ns 2.24285 0.90 393.82ns
re-schedule 10 times 26.03ns 25.727 1.01 478.63ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 530.42ns 432.542 1.23 2350.95ns
just send variadic 1983.20ns 1672.93 1.19 2462.29ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 319.56ns 287.38 1.11 1267.48ns
sending of values from observable via last to subscriber 5.20ns 6.37668 0.82 2.32ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 66.02ns 65.9347 1.00 881.80ns
sending of values from observable via map to subscriber 1.12ns 1.11586 1.01 1.40ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 4280.38ns 4155.39 1.03 9214.84ns
merge_with 4174.03ns 4041.16 1.03 10342.30ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 1222.07ns 1163.65 1.05 9406.73ns
sending of values from observable via observe_on to subscriber 211.52ns 215.378 0.98 839.30ns

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 646.12ns 590.597 1.09 3260.54ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 28.54ns 21.134 1.35 38.07ns
on_error 0.57ns 0.560996 1.02 17.63ns
on_completed 0.59ns 0.560947 1.06 4.30ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 410.42ns 642.55 0.64 537.20ns
get_observable 27.24ns 26.6124 1.02 202.00ns
get_subscriber 55.71ns 53.8332 1.03 80.21ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 6085.67ns 5468.89 1.11 10788.90ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 135.01ns 145.474 0.93 1089.37ns
sending of values from observable via scan to subscriber 2.25ns 3.02426 0.75 2.00ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 1.98ns 3.1477 0.63 .
mutex lock increment 26.98ns 22.8717 1.18 .
spin-lock increment 8.46ns 14.3789 0.59 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 143.34ns 139.334 1.03 1408.20ns
sending of values from observable via skip to subscriber 2.24ns 3.1375 0.71 1.91ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 4858.16ns 4892.26 0.99 11989.50ns
sending of values from observable via switch_on_next to subscriber 970.70ns 987.863 0.98 2795.98ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 293.72ns 334.725 0.88 1843.75ns
sending of values from observable via take to subscriber 3.28ns 3.58657 0.91 5.48ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 307.68ns 530.931 0.58 2015.09ns
sending of values from observable via take_last to subscriber 2.74ns 2.8051 0.98 5.05ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 2558.54ns 2355.71 1.09 4422.66ns
sending of values from observable via take_until to subscriber 8.59ns 13.748 0.63 2.25ns

timeout

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
timeout construction from observable via dot + subscribe with run_loop 7220.64ns 6805.82 1.06 4189.73ns
sending of values from observable via timeout to subscriber with unreachable timeout interval with run_loop 69.37ns 72.7318 0.95 1058.69ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 37.33ns 29.922 1.25 573.71ns
re-schedule 10 times 103.95ns 94.3211 1.10 621.68ns
recursively schedule 10 times 2759.70ns 1990.94 1.39 20010.10ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 4978.22ns 4002.8 1.24 12665.10ns
sending of values from observable via window to subscriber 881.40ns 958.336 0.92 4766.65ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 1757.67ns 1685.27 1.04 .
sending of values from observable via with_latest_from to subscriber 22.90ns 23.1339 0.99 .

ci-ubuntu-clang

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 0.40ns 0.335131 1.20 0.40ns
Dynamic observable construction 18.97ns 18.5818 1.02 30.67ns
Specific observable construction + as_dynamic 18.93ns 18.8043 1.01 30.62ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 51.22ns 50.3603 1.02 340.34ns
Specific observable lift dynamic observer 53.55ns 50.8102 1.05 352.57ns
Dynamic observable lift specific observer 82.56ns 85.2595 0.97 388.27ns
Dynamic observable lift dynamic observer 79.16ns 75.6188 1.05 364.81ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 33.85ns 36.6288 0.92 334.76ns
Specific observable subscribe dynamic observer 34.20ns 37.3093 0.92 342.42ns
Dynamic observable subscribe specific observer 67.36ns 70.2825 0.96 378.90ns
Dynamic observable subscribe dynamic observer 59.63ns 60.4367 0.99 350.08ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 34.40ns 36.9314 0.93 332.29ns
Dynamic observable subscribe lambda 61.07ns 64.8558 0.94 374.46ns
Specific observable subscribe lambda without subscription 32.85ns 36.542 0.90 332.93ns
Dynamic observable subscribe lambda without subscription 60.61ns 64.8341 0.93 374.39ns
Specific observable subscribe specific subscriber 13.65ns 13.7173 0.99 276.32ns
Dynamic observable subscribe specific subscriber 40.08ns 42.9321 0.93 316.60ns
Specific observable subscribe dynamic observer 13.68ns 13.7365 1.00 291.51ns
Dynamic observable subscribe dynamic observer 37.02ns 33.7434 1.10 295.69ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.40ns 0.335157 1.20 0.40ns
Dynamic observer construction 19.27ns 18.4706 1.04 24.85ns
Specific observer construction + as_dynamic 19.15ns 17.9551 1.07 24.48ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.44ns 0.670203 0.66 0.44ns
Dynamic observer OnNext 2.01ns 2.00734 1.00 2.01ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 20.59ns 19.8639 1.04 62.71ns
Make copy of subscriber 10.46ns 6.95542 1.50 10.67ns
Transform subsriber to dynamic 20.86ns 20.697 1.01 29.71ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 20.57ns 20.224 1.02 57.14ns
composite_subscription add 21.41ns 17.7861 1.20 80.36ns
composite_subscription unsubscribe 26.95ns 30.1336 0.89 27.14ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 733.42ns 766.184 0.96 2034.15ns
sending of values from observable via buffer to subscriber 4.82ns 5.02488 0.96 23.71ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 133.63ns 102.498 1.30 608.23ns
long stateful chain creation + subscribe 154.34ns 145.079 1.06 1519.37ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 422.78ns 455.492 0.93 .
sending of values from observable via combine_latest to subscriber 7.79ns 8.01816 0.97 .

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 1819.74ns 1786.49 1.02 3898.89ns
concat_with 1671.78ns 1555.52 1.07 4321.44ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 53.05ns 52.0928 1.02 319.12ns
sending of values from observable via distinct_until_changed to subscriber 2.01ns 1.67714 1.20 1.61ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 83.23ns 82.3694 1.01 772.11ns
sending of values from observable via first to subscriber 0.40ns 0.336162 1.20 0.61ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 37.18ns 36.4263 1.02 721.05ns
error 80.78ns 81.2524 0.99 863.44ns
never 14.60ns 14.4657 1.01 286.29ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 230.56ns 239.46 0.96 750.68ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 0.79ns 0.903482 0.87 125.85ns
re-schedule 10 times 10.04ns 9.03363 1.11 158.61ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 202.52ns 208.529 0.97 708.48ns
just send variadic 1142.47ns 1203.32 0.95 790.61ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 109.95ns 114.335 0.96 457.71ns
sending of values from observable via last to subscriber 3.24ns 2.34756 1.38 1.61ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 41.13ns 30.3811 1.35 311.45ns
sending of values from observable via map to subscriber 1.05ns 0.847597 1.23 2.04ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 1834.70ns 1731.08 1.06 3858.26ns
merge_with 1649.52ns 1546.57 1.07 4205.01ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 549.96ns 551.564 1.00 2710.19ns
sending of values from observable via observe_on to subscriber 122.75ns 129.22 0.95 243.03ns

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 228.56ns 233.195 0.98 760.60ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 20.19ns 19.1515 1.05 13.27ns
on_error 0.81ns 1.01414 0.79 18.95ns
on_completed 1.21ns 1.00941 1.20 0.81ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 112.53ns 118.978 0.95 163.00ns
get_observable 10.70ns 7.89209 1.36 50.28ns
get_subscriber 29.69ns 19.6906 1.51 24.19ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 2089.08ns 2182.6 0.96 3531.79ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 47.26ns 46.0236 1.03 397.41ns
sending of values from observable via scan to subscriber 1.60ns 1.67258 0.96 1.74ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 3.14ns 1.99016 1.58 .
mutex lock increment 6.84ns 8.0415 0.85 .
spin-lock increment 10.43ns 9.12011 1.14 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 47.51ns 45.6164 1.04 564.18ns
sending of values from observable via skip to subscriber 2.63ns 1.67532 1.57 2.53ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 1847.14ns 1841.4 1.00 3660.44ns
sending of values from observable via switch_on_next to subscriber 4027.38ns 4579.6 0.88 863.85ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 81.64ns 81.8632 1.00 608.25ns
sending of values from observable via take to subscriber 2.02ns 2.34605 0.86 2.35ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 110.81ns 115.677 0.96 652.51ns
sending of values from observable via take_last to subscriber 3.25ns 2.36083 1.38 3.81ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 916.05ns 874.839 1.05 1519.36ns
sending of values from observable via take_until to subscriber 10.44ns 8.71932 1.20 2.04ns

timeout

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
timeout construction from observable via dot + subscribe with run_loop 807.91ns 792.076 1.02 13599.60ns
sending of values from observable via timeout to subscriber with unreachable timeout interval with run_loop 42.88ns 41.4548 1.03 12457.70ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 6.89ns 7.88637 0.87 184.75ns
re-schedule 10 times 25.08ns 27.8072 0.90 212.17ns
recursively schedule 10 times 1399.28ns 1420.79 0.98 7713.02ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 1647.05ns 1594.97 1.03 3350.56ns
sending of values from observable via window to subscriber 278.85ns 264.065 1.06 405.72ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 500.69ns 540.517 0.93 .
sending of values from observable via with_latest_from to subscriber 7.35ns 8.81874 0.83 .

ci-ubuntu-gcc

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 0.34ns 0.375776 0.89 0.34ns
Dynamic observable construction 32.54ns 33.4096 0.97 51.81ns
Specific observable construction + as_dynamic 32.52ns 36.1118 0.90 51.94ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 98.90ns 122.669 0.81 732.79ns
Specific observable lift dynamic observer 127.86ns 149.203 0.86 775.32ns
Dynamic observable lift specific observer 183.54ns 211.938 0.87 835.37ns
Dynamic observable lift dynamic observer 195.88ns 244.349 0.80 803.71ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 61.70ns 70.3299 0.88 701.85ns
Specific observable subscribe dynamic observer 79.75ns 92.3954 0.86 732.54ns
Dynamic observable subscribe specific observer 132.40ns 141.062 0.94 790.06ns
Dynamic observable subscribe dynamic observer 128.58ns 153.361 0.84 739.89ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 61.79ns 70.818 0.87 726.28ns
Dynamic observable subscribe lambda 132.95ns 157.563 0.84 785.90ns
Specific observable subscribe lambda without subscription 61.80ns 71.7615 0.86 700.12ns
Dynamic observable subscribe lambda without subscription 132.69ns 150.47 0.88 790.09ns
Specific observable subscribe specific subscriber 30.41ns 35.2654 0.86 596.87ns
Dynamic observable subscribe specific subscriber 98.70ns 112.755 0.88 681.78ns
Specific observable subscribe dynamic observer 30.41ns 35.9291 0.85 623.61ns
Dynamic observable subscribe dynamic observer 85.23ns 100.067 0.85 635.05ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.34ns 0.404165 0.83 0.33ns
Dynamic observer construction 33.11ns 33.9506 0.98 45.38ns
Specific observer construction + as_dynamic 32.50ns 35.2693 0.92 47.91ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.34ns 0.380798 0.88 0.33ns
Dynamic observer OnNext 1.67ns 2.32684 0.72 2.01ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 39.55ns 42.9384 0.92 135.28ns
Make copy of subscriber 16.74ns 19.758 0.85 31.76ns
Transform subsriber to dynamic 45.31ns 49.7084 0.91 78.22ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 35.56ns 39.1849 0.91 128.72ns
composite_subscription add 47.44ns 57.6139 0.82 104.95ns
composite_subscription unsubscribe 43.30ns 50.3817 0.86 38.37ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 953.54ns 1038.62 0.92 2932.58ns
sending of values from observable via buffer to subscriber 6.45ns 7.08022 0.91 30.72ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 288.10ns 355.264 0.81 1367.40ns
long stateful chain creation + subscribe 438.46ns 523.353 0.84 4164.63ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 860.14ns 1075.89 0.80 .
sending of values from observable via combine_latest to subscriber 8.60ns 11.1534 0.77 .

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 2960.67ns 3504.02 0.84 7584.09ns
concat_with 2782.03ns 3346.82 0.83 8045.10ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 121.26ns 149.661 0.81 734.94ns
sending of values from observable via distinct_until_changed to subscriber 2.35ns 2.87762 0.82 1.34ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 174.00ns 206.047 0.84 1706.47ns
sending of values from observable via first to subscriber 1.34ns 0.777266 1.73 1.01ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 66.75ns 83.5839 0.80 1725.69ns
error 119.04ns 133.703 0.89 1752.37ns
never 32.44ns 40.0928 0.81 628.73ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 335.90ns 405.107 0.83 1764.26ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 1.67ns 1.06448 1.57 277.55ns
re-schedule 10 times 22.76ns 29.0529 0.78 307.71ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 300.59ns 366.257 0.82 1763.79ns
just send variadic 1428.83ns 1647.61 0.87 1783.08ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 211.57ns 256.326 0.83 1003.75ns
sending of values from observable via last to subscriber 3.03ns 3.52399 0.86 1.67ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 82.00ns 93.9435 0.87 738.42ns
sending of values from observable via map to subscriber 1.34ns 0.904417 1.48 2.35ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 2907.22ns 3681.91 0.79 9130.85ns
merge_with 2753.94ns 3564.02 0.77 8964.10ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 834.36ns 988.165 0.84 3263.26ns
sending of values from observable via observe_on to subscriber 159.50ns 172.204 0.93 517.68ns

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 446.48ns 543.312 0.82 1522.07ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 22.44ns 27.3717 0.82 16.38ns
on_error 0.67ns 0.732448 0.92 17.22ns
on_completed 0.67ns 0.765834 0.88 1.01ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 212.95ns 275.04 0.77 380.29ns
get_observable 36.09ns 35.3004 1.02 97.86ns
get_subscriber 69.89ns 63.2372 1.11 95.74ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 4234.55ns 5858.45 0.72 7043.28ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 117.03ns 158.377 0.74 910.22ns
sending of values from observable via scan to subscriber 2.01ns 2.81699 0.71 1.59ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 2.01ns 2.58013 0.78 .
mutex lock increment 7.78ns 8.46292 0.92 .
spin-lock increment 9.06ns 14.2013 0.64 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 115.61ns 155.329 0.74 1093.73ns
sending of values from observable via skip to subscriber 2.34ns 3.14706 0.74 2.34ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 3154.74ns 3746.51 0.84 10579.50ns
sending of values from observable via switch_on_next to subscriber 789.88ns 940.639 0.84 2932.21ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 174.60ns 291.639 0.60 1359.83ns
sending of values from observable via take to subscriber 3.69ns 4.34892 0.85 3.49ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 211.74ns 245.439 0.86 1397.43ns
sending of values from observable via take_last to subscriber 3.12ns 3.87188 0.81 5.91ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 1598.49ns 1942.66 0.82 3559.71ns
sending of values from observable via take_until to subscriber 9.04ns 13.1718 0.69 2.34ns

timeout

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
timeout construction from observable via dot + subscribe with run_loop 1117.01ns 1369.31 0.82 15078.00ns
sending of values from observable via timeout to subscriber with unreachable timeout interval with run_loop 62.01ns 65.0374 0.95 2445.47ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 20.91ns 23.5254 0.89 368.50ns
re-schedule 10 times 50.41ns 49.3086 1.02 397.17ns
recursively schedule 10 times 1440.40ns 1670.26 0.86 19789.20ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 2770.49ns 3370.38 0.82 5971.57ns
sending of values from observable via window to subscriber 550.40ns 680.538 0.81 950.36ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 1064.93ns 1323.53 0.80 .
sending of values from observable via with_latest_from to subscriber 9.54ns 11.5037 0.83 .

ci-windows

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 2.01ns 2.00968 1.00 0.41ns
Dynamic observable construction 70.78ns 72.3931 0.98 115.05ns
Specific observable construction + as_dynamic 70.79ns 71.5043 0.99 115.00ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 135.56ns 135.939 1.00 1175.86ns
Specific observable lift dynamic observer 169.59ns 169.877 1.00 1222.29ns
Dynamic observable lift specific observer 265.53ns 265.585 1.00 1356.53ns
Dynamic observable lift dynamic observer 237.89ns 232.972 1.02 1264.70ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 97.04ns 100.348 0.97 1126.14ns
Specific observable subscribe dynamic observer 120.00ns 118.052 1.02 1170.95ns
Dynamic observable subscribe specific observer 206.15ns 207.75 0.99 1295.00ns
Dynamic observable subscribe dynamic observer 168.66ns 171.91 0.98 1202.81ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 97.76ns 98.25 1.00 1140.05ns
Dynamic observable subscribe lambda 204.82ns 205.298 1.00 1291.80ns
Specific observable subscribe lambda without subscription 97.06ns 98.3452 0.99 1136.50ns
Dynamic observable subscribe lambda without subscription 204.26ns 207.692 0.98 1308.26ns
Specific observable subscribe specific subscriber 26.49ns 26.4979 1.00 837.61ns
Dynamic observable subscribe specific subscriber 133.09ns 131.644 1.01 996.16ns
Specific observable subscribe dynamic observer 26.49ns 26.485 1.00 862.62ns
Dynamic observable subscribe dynamic observer 84.03ns 78.7238 1.07 1070.64ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 2.00ns 2.1076 0.95 2.01ns
Dynamic observer construction 70.87ns 72.1111 0.98 105.71ns
Specific observer construction + as_dynamic 70.38ns 71.8246 0.98 104.50ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.45ns 0.44032 1.01 0.80ns
Dynamic observer OnNext 1.63ns 2.00804 0.81 1.60ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 72.46ns 72.6401 1.00 336.73ns
Make copy of subscriber 16.05ns 16.0423 1.00 36.94ns
Transform subsriber to dynamic 86.50ns 86.6748 1.00 140.90ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 72.31ns 73.6294 0.98 315.65ns
composite_subscription add 70.17ns 67.2452 1.04 171.53ns
composite_subscription unsubscribe 60.42ns 61.9353 0.98 114.37ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 1030.29ns 1035.12 1.00 4393.67ns
sending of values from observable via buffer to subscriber 6.95ns 7.41839 0.94 87.11ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 297.56ns 296.225 1.00 1707.33ns
long stateful chain creation + subscribe 669.57ns 654.361 1.02 3227.62ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 1547.31ns 1529.75 1.01 .
sending of values from observable via combine_latest to subscriber 36.20ns 35.8041 1.01 .

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 4024.43ns 4033.83 1.00 10533.00ns
concat_with 4205.17ns 4204.17 1.00 11501.00ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 173.30ns 176.029 0.98 1009.20ns
sending of values from observable via distinct_until_changed to subscriber 3.21ns 3.23416 0.99 3.62ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 217.84ns 217.118 1.00 2673.60ns
sending of values from observable via first to subscriber 2.01ns 2.02735 0.99 1.22ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 63.29ns 63.4333 1.00 2358.82ns
error 121.52ns 120.889 1.01 2493.30ns
never 30.64ns 27.9085 1.10 875.52ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 498.04ns 499.34 1.00 2455.00ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 1.63ns 1.60809 1.01 404.53ns
re-schedule 10 times 130.27ns 130.393 1.00 440.40ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 369.08ns 374.258 0.99 2364.27ns
just send variadic 1284.32ns 1293.65 0.99 2466.40ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 294.76ns 295.026 1.00 1440.06ns
sending of values from observable via last to subscriber 3.98ns 4.36926 0.91 3.33ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 95.44ns 92.5802 1.03 988.77ns
sending of values from observable via map to subscriber 3.54ns 3.59567 0.98 7.15ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 3952.57ns 7112.14 0.56 10988.30ns
merge_with 4101.33ns 4111.17 1.00 11548.70ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 1182.77ns 1197.29 0.99 5479.00ns
sending of values from observable via observe_on to subscriber 194.34ns 194.161 1.00 818.46ns

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 618.89ns 616.949 1.00 1892.62ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 23.15ns 22.9955 1.01 28.38ns
on_error 2.48ns 2.44438 1.02 19.42ns
on_completed 2.84ns 2.86775 0.99 0.81ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 334.94ns 335.339 1.00 610.55ns
get_observable 30.90ns 31.7087 0.97 153.95ns
get_subscriber 63.05ns 61.935 1.02 100.32ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 5862.20ns 5909.4 0.99 11267.70ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 176.40ns 168.154 1.05 1253.65ns
sending of values from observable via scan to subscriber 5.33ns 5.74816 0.93 8.82ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 2.81ns 2.81144 1.00 .
mutex lock increment 24.16ns 24.0078 1.01 .
spin-lock increment 10.44ns 10.7082 0.98 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 168.49ns 166.741 1.01 1554.60ns
sending of values from observable via skip to subscriber 3.21ns 3.22185 1.00 3.51ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 4575.17ns 4628.5 0.99 12066.50ns
sending of values from observable via switch_on_next to subscriber 1081.80ns 1092.9 0.99 3054.11ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 243.72ns 224.398 1.09 2119.08ns
sending of values from observable via take to subscriber 6.11ns 5.46745 1.12 5.71ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 307.37ns 307.68 1.00 2392.09ns
sending of values from observable via take_last to subscriber 4.09ns 4.45248 0.92 19.84ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 2246.09ns 2274.27 0.99 5204.20ns
sending of values from observable via take_until to subscriber 12.08ns 12.5814 0.96 5.23ns

timeout

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
timeout construction from observable via dot + subscribe with run_loop 1640.92ns 1610.23 1.02 5627.00ns
sending of values from observable via timeout to subscriber with unreachable timeout interval with run_loop 58.10ns 58.4382 0.99 1389.19ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 18.81ns 18.6165 1.01 593.14ns
re-schedule 10 times 143.88ns 144.52 1.00 634.45ns
recursively schedule 10 times 2428.64ns 2419.27 1.00 19161.00ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 3656.86ns 3662.0 1.00 9509.00ns
sending of values from observable via window to subscriber 813.07ns 821.581 0.99 1564.25ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 1870.67ns 1872.38 1.00 .
sending of values from observable via with_latest_from to subscriber 26.76ns 31.3294 0.85 .

Please sign in to comment.