Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion .github/workflows/comment_benchmarks_v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Download all workflow run artifacts
uses: dawidd6/action-download-artifact@v6
with:
Expand Down
2 changes: 1 addition & 1 deletion ci/process_benchmark_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ def print_metric(v):
print(f"</details>")

with open("./gh-pages/v2/benchmark_results.json", "w") as f:
json.dump(res, f, indent=4)
json.dump(res, f, indent=4)
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; })
Comment thread
AlexInLog marked this conversation as resolved.
| 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