Skip to content

Commit

Permalink
Add benchmarks (#687)
Browse files Browse the repository at this point in the history
* add benchmarks

* fix

* Update CMakeLists.txt

* Update ci v2.yml

* try to adapt python

* extend benchmarks

* fix

* fix

* renmae

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
victimsnino and pre-commit-ci[bot] authored Nov 23, 2024
1 parent 3ad48b4 commit db32585
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ jobs:
{name: ci-macos, os: macos-12}]
type: [tests, benchmarks]
build_type: [{config: Release, test_preset: ci-tests}, {config: Debug, test_preset: ci-tests-debug}]
optimization_disabled: [{mode: 0, postfix: ""}, {mode: 1, postfix: " (Optimizations disabled)"}]

timeout-minutes: 20
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.type }} ${{ matrix.config.name }} ${{ matrix.build_type.config }}
name: ${{ matrix.type }} ${{ matrix.config.name }} ${{ matrix.build_type.config }}${{ matrix.optimization_disabled.postfix}}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -198,7 +199,7 @@ jobs:
uses: lukka/run-cmake@v10
with:
configurePreset: ${{ matrix.config.name }}-${{ matrix.type }}
configurePresetAdditionalArgs: "['-DCMAKE_BUILD_TYPE=${{ matrix.build_type.config }}', '-DCMAKE_CONFIGURATION_TYPES=${{ matrix.build_type.config }}']"
configurePresetAdditionalArgs: "['-DCMAKE_BUILD_TYPE=${{ matrix.build_type.config }}', '-DCMAKE_CONFIGURATION_TYPES=${{ matrix.build_type.config }}', '-DRPP_DISABLE_DISPOSABLES_OPTIMIZATION=${{matrix.optimization_disabled.mode}}']"
buildPreset: ci-build
buildPresetAdditionalArgs: "['--config ${{ matrix.build_type.config }}']"
testPreset: ${{matrix.build_type.test_preset}}
Expand All @@ -208,7 +209,7 @@ jobs:
uses: actions/upload-artifact@v4
if: matrix.type == 'benchmarks' && matrix.build_type.config == 'Release'
with:
name: ${{ matrix.config.name }}
name: ${{ matrix.config.name }}${{ matrix.optimization_disabled.postfix}}
path: ${{github.workspace}}/build/test_results/benchmarks_results.json

docs:
Expand Down
3 changes: 3 additions & 0 deletions src/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ if (RPP_BUILD_RXCPP)
get_target_property(DEP_DIR rxcpp INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${TARGET} SYSTEM PRIVATE ${DEP_DIR})
endif()
if(RPP_DISABLE_DISPOSABLES_OPTIMIZATION)
target_compile_definitions(${TARGET} PRIVATE "RPP_DISABLE_DISPOSABLES_OPTIMIZATION=${RPP_DISABLE_DISPOSABLES_OPTIMIZATION}")
endif()

set_target_properties(${TARGET} PROPERTIES FOLDER Tests)
set_target_properties(${TARGET} PROPERTIES CXX_CLANG_TIDY "")
Expand Down
127 changes: 127 additions & 0 deletions src/benchmarks/benchmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,133 @@ int main(int argc, char* argv[]) // NOLINT(bugprone-exception-escape)
| rxcpp::operators::subscribe<char>([](char v) { ankerl::nanobench::doNotOptimizeAway(v); });
});
}
SECTION("mix operators with disposables and without disposables")
{
TEST_RPP([&]() {
rpp::subjects::publish_subject<int> s{};
s.get_observable()
| rpp::ops::filter([](int v) -> bool { return v; })
| rpp::ops::finally([]() noexcept { ankerl::nanobench::doNotOptimizeAway(1); })

| rpp::ops::map([](int v) { return rpp::immediate_just(v * 2, v * 3); })
| rpp::ops::concat()

| rpp::ops::filter([](int v) -> bool { return v; })
| rpp::ops::delay(std::chrono::seconds{0}, rpp::schedulers::immediate{})

| rpp::ops::filter([](int v) -> bool { return v; })
| rpp::ops::subscribe([](int v) { ankerl::nanobench::doNotOptimizeAway(v); });
const auto obs = s.get_observer();
obs.on_next(1);
obs.on_completed();
});

TEST_RXCPP([&]() {
rxcpp::subjects::subject<int> s{};
s.get_observable()
| rxcpp::operators::filter([](int v) -> bool { return v; })
| rxcpp::operators::finally([]() noexcept { ankerl::nanobench::doNotOptimizeAway(1); })

| rxcpp::operators::map([](int v) { return rxcpp::immediate_just(v * 2, v * 3); })
| rxcpp::operators::concat()

| rxcpp::operators::filter([](int v) -> bool { return v; })
| rxcpp::operators::delay(std::chrono::seconds{0}, rxcpp::identity_immediate())

| rxcpp::operators::filter([](int v) -> bool { return v; })
| rxcpp::operators::subscribe<int>([](int v) { ankerl::nanobench::doNotOptimizeAway(v); });
const auto obs = s.get_subscriber();
obs.on_next(1);
obs.on_completed();
});
}
SECTION("single disposable and looooooong indentity chain")
{
TEST_RPP([&]() {
const auto d = rpp::composite_disposable_wrapper::make();
rpp::source::create<int>([&](auto&& obs) {
obs.set_upstream(rpp::make_callback_disposable([]() noexcept { ankerl::nanobench::doNotOptimizeAway(1); }));
obs.on_next(1);
obs.on_completed();
})
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::operators::map([](int v) { return v * 2; })
| rpp::ops::subscribe(d, [](int) {});
});

TEST_RXCPP([&]() {
const auto d = rxcpp::composite_subscription{};
rxcpp::observable<>::create<int>([&](auto&& obs) {
obs.get_subscription().add([]() noexcept { ankerl::nanobench::doNotOptimizeAway(1); });
obs.on_next(1);
obs.on_completed();
})
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::map([](int v) { return v * 2; })
| rxcpp::operators::subscribe<int>(d, [](int) {});
});
}

} // BENCHMARK("Scenarios")

if (dump.has_value())
Expand Down
7 changes: 7 additions & 0 deletions src/rpp/rpp/observers/details/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ namespace rpp::details::observers
{
static_assert(mode == disposables_mode::Auto || mode == disposables_mode::None || mode == disposables_mode::External || mode == disposables_mode::Boolean);

#if defined(RPP_DISABLE_DISPOSABLES_OPTIMIZATION) and RPP_DISABLE_DISPOSABLES_OPTIMIZATION
if constexpr (mode == disposables_mode::External)
return static_cast<composite_disposable_wrapper*>(nullptr);
else
return static_cast<default_disposables_strategy*>(nullptr);
#else
if constexpr (mode == disposables_mode::Auto)
return static_cast<default_disposables_strategy*>(nullptr);
else if constexpr (mode == disposables_mode::None)
Expand All @@ -84,6 +90,7 @@ namespace rpp::details::observers
return static_cast<boolean_disposables_strategy*>(nullptr);
else
return static_cast<void*>(nullptr);
#endif
}
} // namespace details

Expand Down

1 comment on commit db32585

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

BENCHMARK RESULTS (AUTOGENERATED)

ci-ubuntu-gcc

General

name rxcpp rpp prev rpp ratio rpp no optimization
Subscribe empty callbacks to empty observable 301.45 ns 1.85 ns 1.85 ns 1.00 1.85 ns
Subscribe empty callbacks to empty observable via pipe operator 304.71 ns 1.85 ns 1.85 ns 1.00 1.85 ns

Sources

name rxcpp rpp prev rpp ratio rpp no optimization
from array of 1 - create + subscribe + immediate 700.24 ns 0.31 ns 0.31 ns 1.00 0.31 ns
from array of 1 - create + subscribe + current_thread 1030.99 ns 3.42 ns 3.42 ns 1.00 3.71 ns
concat_as_source of just(1 immediate) create + subscribe 2266.87 ns 118.56 ns 121.20 ns 0.98 146.03 ns
defer from array of 1 - defer + create + subscribe + immediate 789.49 ns 0.31 ns 0.31 ns 1.00 0.31 ns
interval - interval + take(3) + subscribe + immediate 2185.47 ns 59.23 ns 59.23 ns 1.00 59.23 ns
interval - interval + take(3) + subscribe + current_thread 3052.92 ns 32.42 ns 32.46 ns 1.00 33.95 ns
from array of 1 - create + as_blocking + subscribe + new_thread 29859.83 ns 27793.40 ns 27641.95 ns 1.01 28080.93 ns
from array of 1000 - create + as_blocking + subscribe + new_thread 41990.74 ns 52570.55 ns 50808.10 ns 1.03 51016.09 ns
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 3680.23 ns 137.59 ns 134.11 ns 1.03 152.44 ns

Filtering Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+take(1)+subscribe 1124.59 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just+filter(true)+subscribe 852.16 ns 0.62 ns 0.31 ns 2.01 0.31 ns
immediate_just(1,2)+skip(1)+subscribe 1000.32 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just(1,1,2)+distinct_until_changed()+subscribe 868.17 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just(1,2)+first()+subscribe 1239.82 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just(1,2)+last()+subscribe 907.14 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just+take_last(1)+subscribe 1109.15 ns 18.22 ns 18.53 ns 0.98 19.44 ns
immediate_just(1,2,3)+element_at(1)+subscribe 851.21 ns 0.31 ns 0.31 ns 1.00 0.31 ns

Schedulers

name rxcpp rpp prev rpp ratio rpp no optimization
immediate scheduler create worker + schedule 286.43 ns 1.54 ns 1.54 ns 1.00 0.46 ns
current_thread scheduler create worker + schedule 359.13 ns 4.94 ns 4.63 ns 1.07 4.32 ns
current_thread scheduler create worker + schedule + recursive schedule 815.31 ns 60.64 ns 60.53 ns 1.00 60.97 ns

Transforming Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+map(v*2)+subscribe 881.05 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just+scan(10, std::plus)+subscribe 891.97 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just+flat_map(immediate_just(v*2))+subscribe 2423.66 ns 146.92 ns 139.94 ns 1.05 171.36 ns
immediate_just+buffer(2)+subscribe 1550.49 ns 13.90 ns 14.21 ns 0.98 18.35 ns
immediate_just+window(2)+subscribe + subscsribe inner 2379.82 ns 1338.62 ns 1267.78 ns 1.06 1430.97 ns

Conditional Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+take_while(false)+subscribe 830.16 ns - - 0.00 -
immediate_just+take_while(true)+subscribe 841.74 ns 0.31 ns 0.31 ns 1.00 0.31 ns

Utility Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just(1)+subscribe_on(immediate)+subscribe 1999.08 ns 0.31 ns 0.29 ns 1.05 0.31 ns

Combining Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 3545.65 ns 139.77 ns 165.80 ns 0.84 185.77 ns
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3742.87 ns 158.10 ns 160.10 ns 0.99 174.25 ns
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 132.30 ns 132.75 ns 1.00 188.05 ns
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 3569.89 ns 447.22 ns 382.07 ns 1.17 432.72 ns
immediate_just(1) + zip(immediate_just(2)) + subscribe 2104.50 ns 214.98 ns 211.74 ns 1.02 226.23 ns
immediate_just(immediate_just(1), immediate_just(1)) + concat() + subscribe 3128.95 ns 233.31 ns 211.43 ns 1.10 280.38 ns

Subjects

name rxcpp rpp prev rpp ratio rpp no optimization
publish_subject with 1 observer - on_next 34.47 ns 14.68 ns 14.67 ns 1.00 15.13 ns
subscribe 100 observers to publish_subject 199132.40 ns 17221.46 ns 16207.82 ns 1.06 16090.58 ns
100 on_next to 100 observers to publish_subject 27169.21 ns 18874.64 ns 20212.75 ns 0.93 20567.12 ns

Scenarios

name rxcpp rpp prev rpp ratio rpp no optimization
basic sample 1446.67 ns 13.28 ns 12.96 ns 1.02 24.40 ns
basic sample with immediate scheduler 1375.49 ns 5.55 ns 5.34 ns 1.04 19.15 ns
mix operators with disposables and without disposables 6405.46 ns 1396.22 ns - 0.00 1925.39 ns
single disposable and looooooong indentity chain 23872.98 ns 1063.38 ns - 0.00 4842.82 ns

Aggregating Operators

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

Error Handling Operators

name rxcpp rpp prev rpp ratio rpp no optimization
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 2032.76 ns 990.49 ns 997.94 ns 0.99 1006.95 ns
create(on_error())+retry(1)+subscribe 590.91 ns 110.11 ns 112.13 ns 0.98 145.09 ns

ci-macos

General

name rxcpp rpp prev rpp ratio rpp no optimization
Subscribe empty callbacks to empty observable 971.97 ns 0.70 ns 0.47 ns 1.50 0.79 ns
Subscribe empty callbacks to empty observable via pipe operator 971.94 ns 0.70 ns 0.47 ns 1.50 0.70 ns

Sources

name rxcpp rpp prev rpp ratio rpp no optimization
from array of 1 - create + subscribe + immediate 1920.21 ns 0.23 ns 0.23 ns 1.00 0.26 ns
from array of 1 - create + subscribe + current_thread 2407.95 ns 31.12 ns 33.11 ns 0.94 36.28 ns
concat_as_source of just(1 immediate) create + subscribe 5390.44 ns 318.81 ns 315.41 ns 1.01 319.12 ns
defer from array of 1 - defer + create + subscribe + immediate 1950.66 ns 0.23 ns 0.30 ns 0.77 0.23 ns
interval - interval + take(3) + subscribe + immediate 4939.59 ns 114.33 ns 136.87 ns 0.84 114.40 ns
interval - interval + take(3) + subscribe + current_thread 6004.41 ns 95.72 ns 118.61 ns 0.81 97.41 ns
from array of 1 - create + as_blocking + subscribe + new_thread 87071.69 ns 85962.42 ns 82168.38 ns 1.05 89777.85 ns
from array of 1000 - create + as_blocking + subscribe + new_thread 86744.38 ns 85950.55 ns 87268.00 ns 0.98 93414.50 ns
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 8146.87 ns 361.85 ns 361.38 ns 1.00 363.63 ns

Filtering Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+take(1)+subscribe 2920.35 ns 0.24 ns 0.28 ns 0.86 0.50 ns
immediate_just+filter(true)+subscribe 2162.12 ns 0.24 ns 0.23 ns 1.01 0.24 ns
immediate_just(1,2)+skip(1)+subscribe 2782.06 ns 0.59 ns 0.28 ns 2.09 0.23 ns
immediate_just(1,1,2)+distinct_until_changed()+subscribe 2097.82 ns 0.47 ns 0.57 ns 0.83 0.47 ns
immediate_just(1,2)+first()+subscribe 12254.64 ns 0.24 ns 0.23 ns 1.02 0.24 ns
immediate_just(1,2)+last()+subscribe 14911.20 ns 0.96 ns 0.23 ns 4.11 0.23 ns
immediate_just+take_last(1)+subscribe 3089.71 ns 0.24 ns 0.29 ns 0.81 0.24 ns
immediate_just(1,2,3)+element_at(1)+subscribe 2149.88 ns 0.23 ns 0.24 ns 0.99 0.25 ns

Schedulers

name rxcpp rpp prev rpp ratio rpp no optimization
immediate scheduler create worker + schedule 848.33 ns 0.93 ns 1.12 ns 0.83 0.71 ns
current_thread scheduler create worker + schedule 1201.98 ns 33.01 ns 43.16 ns 0.76 32.14 ns
current_thread scheduler create worker + schedule + recursive schedule 2003.34 ns 201.89 ns 257.69 ns 0.78 199.77 ns

Transforming Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+map(v*2)+subscribe 2092.87 ns 4.20 ns 4.77 ns 0.88 4.21 ns
immediate_just+scan(10, std::plus)+subscribe 2312.03 ns 0.47 ns 0.53 ns 0.88 0.47 ns
immediate_just+flat_map(immediate_just(v*2))+subscribe 5242.61 ns 371.42 ns 433.47 ns 0.86 424.73 ns
immediate_just+buffer(2)+subscribe 2466.79 ns 63.59 ns 73.17 ns 0.87 65.03 ns
immediate_just+window(2)+subscribe + subscsribe inner 5405.33 ns 2369.69 ns 2817.10 ns 0.84 2455.32 ns

Conditional Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+take_while(false)+subscribe 2069.61 ns - - 0.00 -
immediate_just+take_while(true)+subscribe 2092.94 ns 0.23 ns 0.26 ns 0.90 0.24 ns

Utility Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just(1)+subscribe_on(immediate)+subscribe 5008.05 ns 4.90 ns 6.02 ns 0.81 5.03 ns

Combining Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 7469.86 ns 418.48 ns 540.47 ns 0.77 419.83 ns
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 8464.72 ns 410.35 ns 536.73 ns 0.76 450.83 ns
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 453.07 ns 588.14 ns 0.77 455.27 ns
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 8004.91 ns 930.72 ns 1180.96 ns 0.79 936.09 ns
immediate_just(1) + zip(immediate_just(2)) + subscribe 5088.37 ns 826.84 ns 894.58 ns 0.92 889.37 ns
immediate_just(immediate_just(1), immediate_just(1)) + concat() + subscribe 7480.15 ns 657.40 ns 817.71 ns 0.80 656.27 ns

Subjects

name rxcpp rpp prev rpp ratio rpp no optimization
publish_subject with 1 observer - on_next 74.35 ns 49.27 ns 60.77 ns 0.81 50.27 ns
subscribe 100 observers to publish_subject 354290.33 ns 40826.84 ns 48761.32 ns 0.84 41189.86 ns
100 on_next to 100 observers to publish_subject 52820.52 ns 21635.17 ns 24666.16 ns 0.88 21108.54 ns

Scenarios

name rxcpp rpp prev rpp ratio rpp no optimization
basic sample 2900.64 ns 67.94 ns 84.82 ns 0.80 84.52 ns
basic sample with immediate scheduler 2809.90 ns 18.73 ns 21.88 ns 0.86 31.29 ns
mix operators with disposables and without disposables 13892.66 ns 3305.17 ns - 0.00 4429.72 ns
single disposable and looooooong indentity chain 28550.53 ns 1758.82 ns - 0.00 6480.97 ns

Aggregating Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+reduce(10, std::plus)+subscribe 2402.76 ns 0.24 ns 0.27 ns 0.89 0.26 ns

Error Handling Operators

name rxcpp rpp prev rpp ratio rpp no optimization
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 6634.18 ns 4175.64 ns 4711.88 ns 0.89 4225.44 ns
create(on_error())+retry(1)+subscribe 1819.44 ns 276.72 ns 335.57 ns 0.82 280.47 ns

ci-ubuntu-clang

General

name rxcpp rpp prev rpp ratio rpp no optimization
Subscribe empty callbacks to empty observable 280.91 ns 1.54 ns 0.64 ns 2.40 1.54 ns
Subscribe empty callbacks to empty observable via pipe operator 271.05 ns 1.54 ns 0.63 ns 2.43 1.54 ns

Sources

name rxcpp rpp prev rpp ratio rpp no optimization
from array of 1 - create + subscribe + immediate 566.32 ns 0.31 ns 0.31 ns 1.00 0.31 ns
from array of 1 - create + subscribe + current_thread 780.39 ns 4.01 ns 4.01 ns 1.00 4.01 ns
concat_as_source of just(1 immediate) create + subscribe 2539.02 ns 129.52 ns 130.06 ns 1.00 129.28 ns
defer from array of 1 - defer + create + subscribe + immediate 932.55 ns 0.31 ns 0.31 ns 1.00 0.31 ns
interval - interval + take(3) + subscribe + immediate 2495.43 ns 58.30 ns 58.26 ns 1.00 58.60 ns
interval - interval + take(3) + subscribe + current_thread 3437.31 ns 30.88 ns 30.93 ns 1.00 31.49 ns
from array of 1 - create + as_blocking + subscribe + new_thread 27504.86 ns 27385.20 ns 27987.29 ns 0.98 27610.26 ns
from array of 1000 - create + as_blocking + subscribe + new_thread 35723.69 ns 34583.44 ns 35210.87 ns 0.98 36409.72 ns
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 3897.97 ns 148.56 ns 147.80 ns 1.01 148.12 ns

Filtering Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+take(1)+subscribe 1158.45 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just+filter(true)+subscribe 849.03 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just(1,2)+skip(1)+subscribe 1085.02 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just(1,1,2)+distinct_until_changed()+subscribe 872.28 ns 0.62 ns 0.31 ns 2.00 0.31 ns
immediate_just(1,2)+first()+subscribe 1410.51 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just(1,2)+last()+subscribe 1023.54 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just+take_last(1)+subscribe 1188.73 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just(1,2,3)+element_at(1)+subscribe 877.75 ns 0.31 ns 0.31 ns 1.00 0.31 ns

Schedulers

name rxcpp rpp prev rpp ratio rpp no optimization
immediate scheduler create worker + schedule 279.29 ns 0.63 ns 1.54 ns 0.41 0.63 ns
current_thread scheduler create worker + schedule 400.97 ns 4.01 ns 4.02 ns 1.00 4.02 ns
current_thread scheduler create worker + schedule + recursive schedule 858.24 ns 54.97 ns 62.70 ns 0.88 56.85 ns

Transforming Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+map(v*2)+subscribe 866.72 ns 0.31 ns 0.31 ns 1.00 0.31 ns
immediate_just+scan(10, std::plus)+subscribe 1016.84 ns 0.31 ns 0.62 ns 0.50 0.31 ns
immediate_just+flat_map(immediate_just(v*2))+subscribe 2246.76 ns 140.47 ns 137.86 ns 1.02 136.90 ns
immediate_just+buffer(2)+subscribe 1564.37 ns 13.89 ns 14.51 ns 0.96 14.51 ns
immediate_just+window(2)+subscribe + subscsribe inner 2507.74 ns 915.72 ns 905.01 ns 1.01 964.48 ns

Conditional Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+take_while(false)+subscribe 851.40 ns - - 0.00 -
immediate_just+take_while(true)+subscribe 859.84 ns 0.31 ns 0.31 ns 1.00 0.31 ns

Utility Operators

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

Combining Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 3328.51 ns 161.34 ns 159.95 ns 1.01 155.14 ns
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3818.42 ns 139.97 ns 140.22 ns 1.00 139.36 ns
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 141.56 ns 140.15 ns 1.01 138.40 ns
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 3352.91 ns 376.25 ns 376.65 ns 1.00 378.02 ns
immediate_just(1) + zip(immediate_just(2)) + subscribe 2268.54 ns 198.07 ns 211.05 ns 0.94 203.36 ns
immediate_just(immediate_just(1), immediate_just(1)) + concat() + subscribe 3312.96 ns 224.08 ns 223.43 ns 1.00 224.70 ns

Subjects

name rxcpp rpp prev rpp ratio rpp no optimization
publish_subject with 1 observer - on_next 53.94 ns 17.18 ns 17.46 ns 0.98 18.28 ns
subscribe 100 observers to publish_subject 209978.60 ns 16048.06 ns 16052.25 ns 1.00 16223.65 ns
100 on_next to 100 observers to publish_subject 35233.24 ns 23608.45 ns 23453.26 ns 1.01 20622.24 ns

Scenarios

name rxcpp rpp prev rpp ratio rpp no optimization
basic sample 1320.20 ns 11.12 ns 10.81 ns 1.03 20.39 ns
basic sample with immediate scheduler 1309.92 ns 5.86 ns 6.17 ns 0.95 6.79 ns
mix operators with disposables and without disposables 6504.39 ns 1206.85 ns - 0.00 1507.64 ns
single disposable and looooooong indentity chain 27935.66 ns 1249.91 ns - 0.00 4692.36 ns

Aggregating Operators

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

Error Handling Operators

name rxcpp rpp prev rpp ratio rpp no optimization
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 2200.98 ns 1163.40 ns 1174.38 ns 0.99 1145.26 ns
create(on_error())+retry(1)+subscribe 658.64 ns 138.57 ns 138.91 ns 1.00 138.37 ns

ci-windows

General

name rxcpp rpp prev rpp ratio rpp no optimization
Subscribe empty callbacks to empty observable 563.65 ns 1.85 ns 1.85 ns 1.00 1.85 ns
Subscribe empty callbacks to empty observable via pipe operator 582.34 ns 1.85 ns 1.85 ns 1.00 1.85 ns

Sources

name rxcpp rpp prev rpp ratio rpp no optimization
from array of 1 - create + subscribe + immediate 1157.41 ns 5.86 ns 5.24 ns 1.12 4.94 ns
from array of 1 - create + subscribe + current_thread 1411.45 ns 15.75 ns 15.45 ns 1.02 15.45 ns
concat_as_source of just(1 immediate) create + subscribe 3702.27 ns 164.91 ns 173.35 ns 0.95 175.00 ns
defer from array of 1 - defer + create + subscribe + immediate 1192.28 ns 5.55 ns 5.24 ns 1.06 5.24 ns
interval - interval + take(3) + subscribe + immediate 3387.50 ns 141.06 ns 140.92 ns 1.00 141.97 ns
interval - interval + take(3) + subscribe + current_thread 3417.85 ns 59.44 ns 59.06 ns 1.01 62.16 ns
from array of 1 - create + as_blocking + subscribe + new_thread 121720.00 ns 113300.00 ns 114833.33 ns 0.99 117937.50 ns
from array of 1000 - create + as_blocking + subscribe + new_thread 128850.00 ns 130844.44 ns 132387.50 ns 0.99 134200.00 ns
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 5394.71 ns 202.30 ns 213.16 ns 0.95 206.23 ns

Filtering Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+take(1)+subscribe 1820.44 ns 19.74 ns 19.74 ns 1.00 21.36 ns
immediate_just+filter(true)+subscribe 1321.11 ns 18.82 ns 18.81 ns 1.00 21.58 ns
immediate_just(1,2)+skip(1)+subscribe 1742.45 ns 18.52 ns 18.50 ns 1.00 21.60 ns
immediate_just(1,1,2)+distinct_until_changed()+subscribe 1366.95 ns 23.46 ns 23.44 ns 1.00 26.86 ns
immediate_just(1,2)+first()+subscribe 2391.23 ns 17.29 ns 17.29 ns 1.00 19.43 ns
immediate_just(1,2)+last()+subscribe 1475.45 ns 18.52 ns 18.51 ns 1.00 22.83 ns
immediate_just+take_last(1)+subscribe 2008.91 ns 65.01 ns 68.89 ns 0.94 67.48 ns
immediate_just(1,2,3)+element_at(1)+subscribe 1599.44 ns 21.90 ns 21.90 ns 1.00 21.64 ns

Schedulers

name rxcpp rpp prev rpp ratio rpp no optimization
immediate scheduler create worker + schedule 492.59 ns 4.94 ns 4.32 ns 1.14 4.32 ns
current_thread scheduler create worker + schedule 665.01 ns 11.16 ns 11.66 ns 0.96 11.13 ns
current_thread scheduler create worker + schedule + recursive schedule 1089.60 ns 99.72 ns 98.48 ns 1.01 97.79 ns

Transforming Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+map(v*2)+subscribe 1318.76 ns 18.82 ns 18.82 ns 1.00 21.58 ns
immediate_just+scan(10, std::plus)+subscribe 1436.61 ns 21.29 ns 21.29 ns 1.00 23.75 ns
immediate_just+flat_map(immediate_just(v*2))+subscribe 3507.64 ns 186.13 ns 190.79 ns 0.98 203.24 ns
immediate_just+buffer(2)+subscribe 2305.86 ns 64.41 ns 63.43 ns 1.02 69.99 ns
immediate_just+window(2)+subscribe + subscsribe inner 4002.28 ns 1298.10 ns 1311.69 ns 0.99 1335.24 ns

Conditional Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+take_while(false)+subscribe 1321.91 ns 17.57 ns 17.57 ns 1.00 19.11 ns
immediate_just+take_while(true)+subscribe 1329.53 ns 18.82 ns 18.82 ns 1.00 21.59 ns

Utility Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just(1)+subscribe_on(immediate)+subscribe 3596.63 ns 11.10 ns 11.11 ns 1.00 11.10 ns

Combining Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 5138.53 ns 196.76 ns 202.53 ns 0.97 236.63 ns
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 5733.33 ns 185.18 ns 183.10 ns 1.01 200.21 ns
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 193.23 ns 193.49 ns 1.00 196.83 ns
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 5709.09 ns 433.36 ns 462.39 ns 0.94 450.81 ns
immediate_just(1) + zip(immediate_just(2)) + subscribe 3581.88 ns 520.06 ns 528.45 ns 0.98 518.17 ns
immediate_just(immediate_just(1), immediate_just(1)) + concat() + subscribe 4900.48 ns 335.80 ns 334.49 ns 1.00 340.79 ns

Subjects

name rxcpp rpp prev rpp ratio rpp no optimization
publish_subject with 1 observer - on_next 36.19 ns 19.87 ns 20.36 ns 0.98 20.57 ns
subscribe 100 observers to publish_subject 261800.00 ns 28273.68 ns 28097.56 ns 1.01 28560.53 ns
100 on_next to 100 observers to publish_subject 55284.21 ns 32706.25 ns 36128.12 ns 0.91 39188.89 ns

Scenarios

name rxcpp rpp prev rpp ratio rpp no optimization
basic sample 1909.74 ns 96.40 ns 95.69 ns 1.01 111.17 ns
basic sample with immediate scheduler 1897.42 ns 68.77 ns 68.20 ns 1.01 85.00 ns
mix operators with disposables and without disposables 9886.24 ns 2056.47 ns - 0.00 2584.63 ns
single disposable and looooooong indentity chain 26848.84 ns 1725.83 ns - 0.00 6468.36 ns

Aggregating Operators

name rxcpp rpp prev rpp ratio rpp no optimization
immediate_just+reduce(10, std::plus)+subscribe 1460.28 ns 19.43 ns 19.42 ns 1.00 22.82 ns

Error Handling Operators

name rxcpp rpp prev rpp ratio rpp no optimization
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 2009.11 ns 352.88 ns 357.98 ns 0.99 366.75 ns
create(on_error())+retry(1)+subscribe 1794.60 ns 138.21 ns 138.22 ns 1.00 142.08 ns

Please sign in to comment.