MCPcopy Create free account
hub / github.com/AlexInLog/ReactivePlusPlus / main

Function main

src/benchmarks/benchmarks.cpp:79–941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77#endif
78
79int main(int argc, char* argv[]) // NOLINT(bugprone-exception-escape)
80{
81 auto bench = ankerl::nanobench::Bench{}.output(nullptr).warmup(3);
82 const auto args = std::span{argv, static_cast<size_t>(argc)};
83 const auto benchmark = find_argument("--benchmark=", args);
84 const auto section = find_argument("--section=", args);
85 [[maybe_unused]] const auto disable_rxcpp = find_argument("--disable_rxcpp", args).has_value();
86 const auto disable_rpp = find_argument("--disable_rpp", args).has_value();
87 const auto dump = find_argument("--dump=", args);
88
89 BENCHMARK("General")
90 {
91 SECTION("Subscribe empty callbacks to empty observable")
92 {
93 TEST_RPP([&]() {
94 rpp::source::create<int>([&](auto&& observer) {
95 ankerl::nanobench::doNotOptimizeAway(observer);
96 })
97 .subscribe([](int) {});
98 });
99
100 TEST_RXCPP([&]() {
101 rxcpp::observable<>::create<int>([&](auto&& observer) {
102 ankerl::nanobench::doNotOptimizeAway(observer);
103 })
104 .subscribe([](int) {});
105 });
106 }
107
108 SECTION("Subscribe empty callbacks to empty observable via pipe operator")
109 {
110 TEST_RPP([&]() {
111 rpp::source::create<int>([&](auto&& observer) {
112 ankerl::nanobench::doNotOptimizeAway(observer);
113 })
114 | rpp::operators::subscribe([](int) {});
115 });
116
117 TEST_RXCPP([&]() {
118 rxcpp::observable<>::create<int>([&](auto&& observer) {
119 ankerl::nanobench::doNotOptimizeAway(observer);
120 })
121 | rxcpp::operators::subscribe<int>([](int) {});
122 });
123 }
124 }; // BENCHMARK("General")
125
126 BENCHMARK("Sources")
127 {
128 SECTION("from array of 1 - create + subscribe + immediate")
129 {
130 std::array<int, 1> vals{123};
131 TEST_RPP([&]() {
132 rpp::source::from_iterable(vals, rpp::schedulers::immediate{}).subscribe([](int v) { ankerl::nanobench::doNotOptimizeAway(v); });
133 });
134
135 TEST_RXCPP([&]() {
136 rxcpp::observable<>::iterate(vals, rxcpp::identity_immediate()).subscribe([](int v) { ankerl::nanobench::doNotOptimizeAway(v); });

Callers

nothing calls this directly

Calls 15

find_argumentFunction · 0.85
subscribeFunction · 0.85
from_iterableFunction · 0.85
as_blockingFunction · 0.85
justFunction · 0.85
deferFunction · 0.85
intervalFunction · 0.85
takeFunction · 0.85
immediate_justFunction · 0.85
mergeFunction · 0.85
merge_withFunction · 0.85
with_latest_fromFunction · 0.85

Tested by

no test coverage detected