Skip to content

Commit

Permalink
Relax code (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
victimsnino authored May 12, 2022
1 parent eb82acb commit 3e1fa5f
Show file tree
Hide file tree
Showing 21 changed files with 243 additions and 299 deletions.
48 changes: 24 additions & 24 deletions src/include/rpp/observables/interface_observable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ concept lift_fn = constraint::subscriber<std::invoke_result_t<T, dynamic_subscri

template<typename T, typename TObservable>
concept op_fn = constraint::observable<std::invoke_result_t<T, TObservable>>;

template<constraint::decayed_type NewType, details::lift_fn<NewType> OperatorFn, typename FwdThis>
auto lift_impl(OperatorFn&& op, FwdThis&& _this)
{
auto action = [new_this = std::forward<FwdThis>(_this), op = std::forward<OperatorFn>(op)](auto&& subscriber)
{
new_this.subscribe(op(std::forward<decltype(subscriber)>(subscriber)));
};

return specific_observable<NewType, decltype(action)>(std::move(action));
}
} // namespace rpp::details

namespace rpp
Expand Down Expand Up @@ -103,13 +114,13 @@ struct interface_observable
template<constraint::decayed_type NewType>
auto lift(details::lift_fn<NewType> auto&& op) const &
{
return lift_impl<NewType>(std::forward<decltype(op)>(op), CastThis());
return details::lift_impl<NewType>(std::forward<decltype(op)>(op), CastThis());
}

template<constraint::decayed_type NewType>
auto lift(details::lift_fn<NewType> auto&& op) &&
{
return lift_impl<NewType>(std::forward<decltype(op)>(op), MoveThis());
return details::lift_impl<NewType>(std::forward<decltype(op)>(op), MoveThis());
}

// ********************************* LIFT OPERATOR: SUBSCRIBER -> SUBSCRIBER ******************//
Expand Down Expand Up @@ -147,13 +158,13 @@ struct interface_observable
template<constraint::decayed_type NewType,
std::invocable<Type, dynamic_subscriber<NewType>> OnNext,
std::invocable<std::exception_ptr, dynamic_subscriber<NewType>> OnError = details::forwarding_on_error,
std::invocable<dynamic_subscriber<NewType>> OnCompleted = details::forwarding_on_completed>
std::invocable<dynamic_subscriber<NewType>> OnCompleted = details::forwarding_on_completed>
auto lift(OnNext&& on_next, OnError&& on_error = {}, OnCompleted&& on_completed = {}) const &
{
return lift_impl<NewType>(details::make_lift_action_by_callbacks<Type>(std::forward<OnNext>(on_next),
std::forward<OnError>(on_error),
std::forward<OnCompleted>(on_completed)),
CastThis());
return details::lift_impl<NewType>(details::make_lift_action_by_callbacks<Type>(std::forward<OnNext>(on_next),
std::forward<OnError>(on_error),
std::forward<OnCompleted>(on_completed)),
CastThis());
}

template<constraint::decayed_type NewType,
Expand All @@ -162,10 +173,10 @@ struct interface_observable
std::invocable<dynamic_subscriber<NewType>> OnCompleted = details::forwarding_on_completed>
auto lift(OnNext&& on_next, OnError&& on_error = {}, OnCompleted&& on_completed = {}) &&
{
return lift_impl<NewType>(details::make_lift_action_by_callbacks<Type>(std::forward<OnNext>(on_next),
std::forward<OnError>(on_error),
std::forward<OnCompleted>(on_completed)),
MoveThis());
return details::lift_impl<NewType>(details::make_lift_action_by_callbacks<Type>(std::forward<OnNext>(on_next),
std::forward<OnError>(on_error),
std::forward<OnCompleted>(on_completed)),
MoveThis());
}

// ********************************* LIFT OnNext, Onerror, OnCompleted ******************//
Expand Down Expand Up @@ -245,21 +256,10 @@ struct interface_observable
{
return std::move(*static_cast<SpecificObservable*>(this));
}

template<constraint::decayed_type NewType, details::lift_fn<NewType> OperatorFn, typename FwdThis>
static auto lift_impl(OperatorFn&& op, FwdThis&& _this)
{
auto action = [new_this = std::forward<FwdThis>(_this), op = std::forward<OperatorFn>(op)](auto&& subscriber)
{
new_this.subscribe(op(std::forward<decltype(subscriber)>(subscriber)));
};

return specific_observable<NewType, decltype(action)>(std::move(action));
}
};

template<constraint::observable Observable,
details::op_fn<Observable> Operator>
template<constraint::observable Observable,
details::op_fn<Observable> Operator>
auto operator |(Observable&& observable, Operator&& op)
{
return std::forward<Observable>(observable).op(std::forward<Operator>(op));
Expand Down
17 changes: 2 additions & 15 deletions src/include/rpp/operators/filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,14 @@
#include <rpp/subscribers/constraints.hpp>
#include <rpp/utils/utilities.hpp>


#include <utility>

IMPLEMENTATION_FILE(filter_tag);

namespace rpp::operators
{
template<typename Predicate>
auto filter(Predicate&& predicate) requires details::is_header_included<details::filter_tag, Predicate>
{
return [predicate = std::forward<Predicate>(predicate)]<constraint::observable TObservable>(TObservable && observable)
{
return std::forward<TObservable>(observable).filter(predicate);
};
}
} // namespace rpp::operators
namespace rpp::details
{
template<constraint::decayed_type Type, typename SpecificObservable>
template<std::predicate<const Type&> Predicate>
auto member_overload<Type, SpecificObservable, filter_tag>::filter_impl(Predicate&& predicate)
template<constraint::decayed_type Type, std::predicate<const Type&> Predicate>
auto filter_impl(Predicate&& predicate)
{
return [predicate = std::forward<Predicate>(predicate)](auto&& value, const constraint::subscriber_of_type<Type> auto& subscriber)
{
Expand Down
74 changes: 41 additions & 33 deletions src/include/rpp/operators/fwd/filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,62 @@
#pragma once

#include <rpp/observables/member_overload.hpp>
#include <rpp/observables/constraints.hpp>

namespace rpp::details
{
struct filter_tag;
}

namespace rpp::operators
{
/**
* \copydoc rpp::details::member_overload::filter
*/
template<typename Predicate>
auto filter(Predicate&& predicate) requires details::is_header_included<details::filter_tag, Predicate>;
auto filter(Predicate&& predicate) requires details::is_header_included<details::filter_tag, Predicate>
{
return[predicate = std::forward<Predicate>(predicate)]<constraint::observable TObservable>(TObservable && observable)
{
return std::forward<TObservable>(observable).filter(predicate);
};
}

} // namespace rpp::operators

namespace rpp::details
{
template<constraint::decayed_type Type, typename SpecificObservable>
struct member_overload<Type, SpecificObservable, filter_tag>
{
/**
* \brief emit only those items from an Observable that satisfies a predicate
*
* \details The Filter operator applies a provided predicate to each item emitted by the Observable, and returns an Observable that emits only items passed provided predicate
*
* Example:
* \snippet filter.cpp Filter
*
* \see https://reactivex.io/documentation/operators/filter.html
*
* \tparam Predicate type of predicate used to check emitted itemss
* \return new specific_observable with the Filter operator as most recent operator.
* \warning #include <rpp/operators/filter.hpp>
* \ingroup operators
*/
template<std::predicate<const Type&> Predicate>
auto filter(Predicate&& predicate) const& requires is_header_included<filter_tag, Predicate>
{
return static_cast<const SpecificObservable*>(this)->template lift <Type>(filter_impl(std::forward<Predicate>(predicate)));
}
template<constraint::decayed_type Type, std::predicate<const Type&> Predicate>
auto filter_impl(Predicate&& predicate);

template<std::predicate<const Type&> Predicate>
auto filter(Predicate&& predicate) && requires is_header_included<filter_tag, Predicate>
{
return std::move(*static_cast<SpecificObservable*>(this)).template lift<Type>(filter_impl(std::forward<Predicate>(predicate)));
}
template<constraint::decayed_type Type, typename SpecificObservable>
struct member_overload<Type, SpecificObservable, filter_tag>
{
/**
* \brief emit only those items from an Observable that satisfies a predicate
*
* \details The Filter operator applies a provided predicate to each item emitted by the Observable, and returns an Observable that emits only items passed provided predicate
*
* Example:
* \snippet filter.cpp Filter
*
* \see https://reactivex.io/documentation/operators/filter.html
*
* \tparam Predicate type of predicate used to check emitted itemss
* \return new specific_observable with the Filter operator as most recent operator.
* \warning #include <rpp/operators/filter.hpp>
* \ingroup operators
*/
template<std::predicate<const Type&> Predicate>
auto filter(Predicate&& predicate) const& requires is_header_included<filter_tag, Predicate>
{
return static_cast<const SpecificObservable*>(this)->template lift <Type>(filter_impl<Type>(std::forward<Predicate>(predicate)));
}

private:
template<std::predicate<const Type&> Predicate>
static auto filter_impl(Predicate&& predicate);
};
template<std::predicate<const Type&> Predicate>
auto filter(Predicate&& predicate) && requires is_header_included<filter_tag, Predicate>
{
return std::move(*static_cast<SpecificObservable*>(this)).template lift<Type>(filter_impl<Type>(std::forward<Predicate>(predicate)));
}
};
} // namespace rpp::details
20 changes: 13 additions & 7 deletions src/include/rpp/operators/fwd/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#pragma once

#include <rpp/observables/member_overload.hpp>
#include <rpp/observables/constraints.hpp>

namespace rpp::details
{
Expand All @@ -23,11 +24,20 @@ namespace rpp::operators
* \copydoc rpp::details::member_overload::map
*/
template<typename Callable>
auto map(Callable&& callable) requires details::is_header_included<details::map_tag, Callable>;
auto map(Callable&& callable) requires details::is_header_included<details::map_tag, Callable>
{
return[callable = std::forward<Callable>(callable)]<constraint::observable TObservable>(TObservable && observable)
{
return std::forward<TObservable>(observable).map(callable);
};
}
} // namespace rpp::operators

namespace rpp::details
{
template<constraint::decayed_type Type, std::invocable<Type> Callable>
auto map_impl(Callable&& callable);

template<constraint::decayed_type Type, typename SpecificObservable>
struct member_overload<Type, SpecificObservable, map_tag>
{
Expand All @@ -54,17 +64,13 @@ struct member_overload<Type, SpecificObservable, map_tag>
template<std::invocable<Type> Callable>
auto map(Callable&& callable) const & requires is_header_included<map_tag, Callable>
{
return static_cast<const SpecificObservable*>(this)->template lift<std::invoke_result_t<Callable, Type>>(map_impl(std::forward<Callable>(callable)));
return static_cast<const SpecificObservable*>(this)->template lift<std::invoke_result_t<Callable, Type>>(map_impl<Type>(std::forward<Callable>(callable)));
}

template<std::invocable<Type> Callable>
auto map(Callable&& callable) && requires is_header_included<map_tag, Callable>
{
return std::move(*static_cast<SpecificObservable*>(this)).template lift<std::invoke_result_t<Callable, Type>>(map_impl(std::forward<Callable>(callable)));
return std::move(*static_cast<SpecificObservable*>(this)).template lift<std::invoke_result_t<Callable, Type>>(map_impl<Type>(std::forward<Callable>(callable)));
}

private:
template<std::invocable<Type> Callable>
static auto map_impl(Callable&& callable);
};
} // namespace rpp::details
42 changes: 30 additions & 12 deletions src/include/rpp/operators/fwd/merge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,38 @@ struct merge_tag;
namespace rpp::operators
{
/**
* \copydoc rpp::details::member_overload::merge
* \copydoc rpp::details::member_overload::merge_with
*/
template<constraint::observable ...TObservables>
auto merge(TObservables&&... observables) requires details::is_header_included<details::merge_tag, TObservables...>;
auto merge_with(TObservables&&... observables) requires details::is_header_included<details::merge_tag, TObservables...>
{
return[...observables = std::forward<TObservables>(observables)]<constraint::observable TObservable>(TObservable && observable)
{
return std::forward<TObservable>(observable).merge_with(observables...);
};
}

/**
* \copydoc rpp::details::member_overload::merge
*/
template<typename ...Args>
auto merge() requires details::is_header_included<details::merge_tag, Args...>
{
return[]<constraint::observable TObservable>(TObservable && observable)
{
return std::forward<TObservable>(observable).merge();
};
}
} // namespace rpp::operators

namespace rpp::details
{
template<constraint::decayed_type Type>
auto merge_impl();

template<constraint::decayed_type Type, constraint::observable_of_type<Type> ...TObservables>
auto merge_with_impl(TObservables&& ...observables) requires (sizeof...(TObservables) >= 1);

template<constraint::decayed_type Type, typename SpecificObservable>
struct member_overload<Type, SpecificObservable, merge_tag>
{
Expand All @@ -49,13 +73,13 @@ struct member_overload<Type, SpecificObservable, merge_tag>
template<typename ...Args>
auto merge() const& requires (is_header_included<merge_tag, Args...> && rpp::constraint::observable<Type>)
{
return static_cast<const SpecificObservable*>(this)->template lift<utils::extract_observable_type_t<Type>>(merge_impl());
return static_cast<const SpecificObservable*>(this)->template lift<utils::extract_observable_type_t<Type>>(merge_impl<Type>());
}

template<typename ...Args>
auto merge() && requires (is_header_included<merge_tag, Args...>&& rpp::constraint::observable<Type>)
{
return std::move(*static_cast<SpecificObservable*>(this)).template lift<utils::extract_observable_type_t<Type>>(merge_impl());
return std::move(*static_cast<SpecificObservable*>(this)).template lift<utils::extract_observable_type_t<Type>>(merge_impl<Type>());
}

/**
Expand All @@ -75,19 +99,13 @@ struct member_overload<Type, SpecificObservable, merge_tag>
template<constraint::observable_of_type<Type> ...TObservables>
auto merge_with(TObservables&&... observables) const& requires (is_header_included<merge_tag, TObservables...>&& sizeof...(TObservables) >= 1)
{
return static_cast<const SpecificObservable*>(this)->op(merge_with_impl(std::forward<TObservables>(observables)...));
return static_cast<const SpecificObservable*>(this)->op(merge_with_impl<Type>(std::forward<TObservables>(observables)...));
}

template<constraint::observable_of_type<Type> ...TObservables>
auto merge_with(TObservables&&... observables) && requires (is_header_included<merge_tag, TObservables...> && sizeof...(TObservables) >= 1)
{
return std::move(*static_cast<SpecificObservable*>(this)).op(merge_with_impl(std::forward<TObservables>(observables)...));
return std::move(*static_cast<SpecificObservable*>(this)).op(merge_with_impl<Type>(std::forward<TObservables>(observables)...));
}

private:
static auto merge_impl();

template<constraint::observable_of_type<Type> ...TObservables>
static auto merge_with_impl(TObservables&& ...observables) requires (sizeof...(TObservables) >= 1);
};
} // namespace rpp::details
20 changes: 13 additions & 7 deletions src/include/rpp/operators/fwd/multicast.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <rpp/observables/member_overload.hpp>
#include <rpp/observables/constraints.hpp>
#include <rpp/subjects/constraints.hpp>

namespace rpp::details
Expand All @@ -13,11 +14,20 @@ namespace rpp::operators
* \copydoc rpp::details::member_overload::multicast
*/
template<rpp::subjects::constraint::subject TSubject>
auto multicast(TSubject&& subject) requires details::is_header_included<details::multicast_tag, TSubject>;
auto multicast(TSubject&& subject) requires details::is_header_included<details::multicast_tag, TSubject>
{
return[subject = std::forward<TSubject>(subject)]<constraint::observable TObservable>(TObservable && observable)
{
return std::forward<TObservable>(observable).multicast(subject);
};
}
} // namespace rpp::operators

namespace rpp::details
{
template<constraint::decayed_type Type, constraint::observable_of_type<Type> TObs, rpp::subjects::constraint::subject_of_type<Type> TSubject>
auto multicast_impl(TObs&& observable, TSubject&& subject);

template<constraint::decayed_type Type, typename SpecificObservable>
struct member_overload<Type, SpecificObservable, multicast_tag>
{
Expand All @@ -36,17 +46,13 @@ struct member_overload<Type, SpecificObservable, multicast_tag>
template<rpp::subjects::constraint::subject_of_type<Type> TSubject>
auto multicast(TSubject&& subject) const& requires is_header_included<multicast_tag, TSubject>
{
return multicast_impl(*static_cast<const SpecificObservable*>(this), std::forward<TSubject>(subject));
return multicast_impl<Type>(*static_cast<const SpecificObservable*>(this), std::forward<TSubject>(subject));
}

template<rpp::subjects::constraint::subject_of_type<Type> TSubject>
auto multicast(TSubject&& subject) && requires is_header_included<multicast_tag, TSubject>
{
return multicast_impl(std::move(*static_cast<SpecificObservable*>(this)), std::forward<TSubject>(subject));
return multicast_impl<Type>(std::move(*static_cast<SpecificObservable*>(this)), std::forward<TSubject>(subject));
}

private:
template<constraint::decayed_same_as<SpecificObservable> TThis, rpp::subjects::constraint::subject_of_type<Type> TSubject>
static auto multicast_impl(TThis&& observable, TSubject&& subject);
};
} // namespace rpp::details
Loading

1 comment on commit 3e1fa5f

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

Linux CLANG

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 0.66ns 0.781133 0.84 0.32ns
Dynamic observable construction 28.69ns 31.9559 0.90 24.56ns
Specific observable construction + as_dynamic 33.00ns 34.6901 0.95 27.26ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 84.61ns 99.2257 0.85 307.77ns
Specific observable lift dynamic observer 129.39ns 131.179 0.99 327.21ns
Dynamic observable lift specific observer 173.55ns 206.558 0.84 427.74ns
Dynamic observable lift dynamic observer 184.39ns 215.784 0.85 342.30ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 66.04ns 66.3889 0.99 306.76ns
Specific observable subscribe dynamic observer 77.89ns 87.4124 0.89 308.61ns
Dynamic observable subscribe specific observer 125.49ns 150.068 0.84 348.14ns
Dynamic observable subscribe dynamic observer 128.41ns 146.42 0.88 322.68ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 65.00ns 69.5328 0.93 285.16ns
Dynamic observable subscribe lambda 132.75ns 146.671 0.91 339.85ns
Specific observable subscribe lambda without subscription 58.49ns 68.0275 0.86 320.02ns
Dynamic observable subscribe lambda without subscription 119.60ns 141.049 0.85 476.03ns
Specific observable subscribe specific subscriber 16.85ns 19.5028 0.86 244.15ns
Dynamic observable subscribe specific subscriber 79.20ns 93.3711 0.85 336.97ns
Specific observable subscribe dynamic observer 17.14ns 20.1187 0.85 245.11ns
Dynamic observable subscribe dynamic observer 67.13ns 75.0375 0.89 276.12ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.66ns 0.769373 0.86 0.35ns
Dynamic observer construction 31.31ns 32.142 0.97 21.22ns
Specific observer construction + as_dynamic 27.97ns 34.0921 0.82 20.00ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.68ns 0.744452 0.91 0.65ns
Dynamic observer OnNext 2.21ns 2.29188 0.97 2.02ns

Operators

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 91.54ns 98.8806 0.93 252.73ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 43.88ns 52.6176 0.83 63.68ns
Make copy of subscriber 16.86ns 18.6789 0.90 5.21ns
Transform subsriber to dynamic 44.01ns 55.2743 0.80 37.25ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 37.21ns 39.0077 0.95 52.10ns
composite_subscription add 68.71ns 73.0245 0.94 23.94ns
composite_subscription unsubscribe 6.18ns 6.69025 0.92 9.73ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 20.09ns 21.9692 0.91 34.84ns
error 45.65ns 58.1207 0.79 73.09ns
never 16.87ns 19.3688 0.87 260.58ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 30.93ns 35.7405 0.87 60.52ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 20.93ns 21.1616 0.99 33.38ns
just send variadic 20.61ns 24.0147 0.86 44.13ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 318.64ns 339.776 0.94 138.53ns
merge_with 388.99ns 443.037 0.88 329.88ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 48.21ns 55.8265 0.86 9.59ns
on_error 2.05ns 2.98933 0.69 18.60ns
on_completed 2.53ns 1.85729 1.36 0.49ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 201.34ns 235.126 0.86 216.26ns
get_observable 41.85ns 50.1616 0.83 51.06ns
get_subscriber 64.47ns 82.6961 0.78 13.49ns

Linux GCC

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 0.34ns 0.334574 1.01 0.34ns
Dynamic observable construction 20.16ns 20.4471 0.99 24.38ns
Specific observable construction + as_dynamic 20.58ns 20.9466 0.98 24.18ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 31.75ns 30.5981 1.04 352.95ns
Specific observable lift dynamic observer 38.42ns 38.4996 1.00 369.80ns
Dynamic observable lift specific observer 67.77ns 67.7271 1.00 409.18ns
Dynamic observable lift dynamic observer 66.38ns 64.9676 1.02 386.04ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 27.03ns 26.5829 1.02 344.43ns
Specific observable subscribe dynamic observer 29.62ns 28.4208 1.04 363.15ns
Dynamic observable subscribe specific observer 59.56ns 60.1465 0.99 409.55ns
Dynamic observable subscribe dynamic observer 49.19ns 49.8372 0.99 371.12ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 26.64ns 27.4562 0.97 341.49ns
Dynamic observable subscribe lambda 60.98ns 59.7055 1.02 417.82ns
Specific observable subscribe lambda without subscription 27.33ns 26.9639 1.01 341.98ns
Dynamic observable subscribe lambda without subscription 61.13ns 59.6364 1.03 401.07ns
Specific observable subscribe specific subscriber 3.65ns 3.67133 0.99 285.83ns
Dynamic observable subscribe specific subscriber 31.06ns 31.7834 0.98 336.19ns
Specific observable subscribe dynamic observer 3.66ns 3.60138 1.02 290.89ns
Dynamic observable subscribe dynamic observer 15.65ns 15.8206 0.99 312.12ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.33ns 0.335827 1.00 0.34ns
Dynamic observer construction 20.43ns 20.4297 1.00 22.62ns
Specific observer construction + as_dynamic 20.65ns 20.8262 0.99 22.39ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.33ns 0.335012 1.00 0.33ns
Dynamic observer OnNext 2.01ns 1.67577 1.20 2.01ns

Operators

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 21.79ns 21.8423 1.00 354.43ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 31.24ns 30.766 1.02 64.37ns
Make copy of subscriber 3.73ns 3.73994 1.00 4.49ns
Transform subsriber to dynamic 24.95ns 22.6911 1.10 29.48ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 22.77ns 22.1005 1.03 59.37ns
composite_subscription add 22.40ns 22.3516 1.00 17.07ns
composite_subscription unsubscribe 8.36ns 6.85921 1.22 10.05ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 4.70ns 4.89893 0.96 52.13ns
error 35.49ns 35.4787 1.00 82.42ns
never 3.55ns 3.55668 1.00 284.31ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 23.86ns 25.1188 0.95 69.22ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 3.98ns 3.97763 1.00 50.80ns
just send variadic 4.71ns 4.69794 1.00 48.21ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 164.33ns 162.163 1.01 146.30ns
merge_with 198.71ns 200.801 0.99 356.92ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 14.11ns 14.4112 0.98 11.04ns
on_error 3.26ns 3.18358 1.02 16.83ns
on_completed 3.01ns 2.51168 1.20 1.01ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 137.47ns 135.153 1.02 176.03ns
get_observable 7.08ns 8.1324 0.87 48.91ns
get_subscriber 13.94ns 14.1277 0.99 22.25ns

Windows MSVC

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 0.80ns 0.592497 1.35 0.69ns
Dynamic observable construction 91.36ns 73.018 1.25 141.16ns
Specific observable construction + as_dynamic 104.58ns 73.1201 1.43 151.88ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 339.02ns 138.039 2.46 1618.14ns
Specific observable lift dynamic observer 197.31ns 182.64 1.08 1357.33ns
Dynamic observable lift specific observer 345.57ns 285.057 1.21 1635.05ns
Dynamic observable lift dynamic observer 305.08ns 243.883 1.25 1361.50ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 136.05ns 105.159 1.29 1511.92ns
Specific observable subscribe dynamic observer 154.61ns 119.286 1.30 1376.30ns
Dynamic observable subscribe specific observer 270.55ns 209.846 1.29 1483.80ns
Dynamic observable subscribe dynamic observer 203.19ns 164.088 1.24 1762.19ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 127.47ns 106.349 1.20 1255.71ns
Dynamic observable subscribe lambda 281.64ns 208.838 1.35 1409.79ns
Specific observable subscribe lambda without subscription 132.74ns 106.274 1.25 1416.96ns
Dynamic observable subscribe lambda without subscription 279.27ns 207.445 1.35 1485.76ns
Specific observable subscribe specific subscriber 18.98ns 14.7873 1.28 960.91ns
Dynamic observable subscribe specific subscriber 129.86ns 117.324 1.11 1063.00ns
Specific observable subscribe dynamic observer 18.71ns 14.7775 1.27 1098.34ns
Dynamic observable subscribe dynamic observer 120.31ns 66.817 1.80 1020.27ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.78ns 0.591689 1.32 1.81ns
Dynamic observer construction 94.77ns 72.2536 1.31 155.86ns
Specific observer construction + as_dynamic 87.91ns 72.0266 1.22 127.53ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.70ns 0.592345 1.18 0.84ns
Dynamic observer OnNext 3.90ns 1.48206 2.63 2.72ns

Operators

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 113.82ns 92.1136 1.24 1221.36ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 118.71ns 90.1599 1.32 484.90ns
Make copy of subscriber 15.51ns 14.7768 1.05 34.50ns
Transform subsriber to dynamic 94.32ns 86.1399 1.09 183.59ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 108.92ns 81.1451 1.34 505.67ns
composite_subscription add 129.04ns 77.9816 1.65 70.63ns
composite_subscription unsubscribe 6.71ns 7.41274 0.91 28.27ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 19.06ns 16.3248 1.17 224.82ns
error 63.96ns 44.7185 1.43 238.34ns
never 20.92ns 14.7759 1.42 1002.00ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 105.77ns 76.3173 1.39 332.68ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 24.45ns 20.4455 1.20 209.36ns
just send variadic 27.84ns 21.5822 1.29 216.46ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 538.50ns 450.561 1.20 746.94ns
merge_with 801.06ns 635.902 1.26 1620.85ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 37.59ns 28.381 1.32 32.64ns
on_error 2.81ns 2.89358 0.97 21.55ns
on_completed 2.56ns 2.28571 1.12 0.75ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 394.97ns 344.302 1.15 746.53ns
get_observable 42.92ns 38.6842 1.11 170.12ns
get_subscriber 66.56ns 51.3932 1.30 109.91ns

Please sign in to comment.