Skip to content

Commit

Permalink
Add initial support for GRPC++ (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
victimsnino authored Jun 20, 2024
1 parent f58e94d commit 973c278
Show file tree
Hide file tree
Showing 27 changed files with 1,288 additions and 40 deletions.
3 changes: 2 additions & 1 deletion BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ But RPP is header-only library, so, without enabling any extra options is just c
- `RPP_BUILD_TESTS` - (ON/OFF) build unit tests (default OFF)
- `RPP_BUILD_EXAMPLES` - (ON/OFF) build examples of usage of RPP (default OFF)
- `RPP_BUILD_SFML_CODE` - (ON/OFF) build RPP code related to SFML or not (default OFF) - requires SFML to be installed
- `RPP_BUILD_QT_CODE` - (ON/OFF) build RPPQT related code (examples/tests)(rppqt module doesn't requires this one) (default OFF) - requires QT5/6 to be installed
- `RPP_BUILD_QT_CODE` - (ON/OFF) build QT related code (examples/tests)(rppqt module doesn't requires this one) (default OFF) - requires QT5/6 to be installed
- `RPP_BUILD_GRPC_CODE` - (ON/OFF) build GRPC related code (examples/tests)(rppgrpc module doesn't requires this one) (default OFF) - requires grpc++/protobuf to be installed

By default, it provides rpp and rppqt INTERFACE modules.

Expand Down
30 changes: 19 additions & 11 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@
"RPP_BUILD_QT_CODE" : "ON"
}
},
{
"name" : "build-grpc",
"hidden": true,
"cacheVariables": {
"RPP_BUILD_GRPC_CODE" : "ON"
}
},
{
"name" : "use-conan",
"hidden": true,
Expand All @@ -149,6 +156,7 @@
},
{
"name": "build-dir",
"hidden": true,
"binaryDir": "${sourceDir}/build"
},

Expand All @@ -160,7 +168,7 @@
},
{
"name": "ci-coverage-gcc",
"inherits": ["ci-build", "build-tests", "build-qt", "ci-unix", "ci-gcc"],
"inherits": ["ci-build", "build-tests", "build-qt", "build-grpc", "ci-unix", "ci-gcc"],
"cacheVariables": {
"RPP_ENABLE_COVERAGE": "ON",
"CMAKE_CXX_FLAGS": "-O0 -g --coverage -fkeep-inline-functions -fkeep-static-functions -fprofile-arcs -ftest-coverage -fno-inline -fno-omit-frame-pointer -fno-optimize-sibling-calls",
Expand All @@ -171,7 +179,7 @@
},
{
"name": "ci-coverage-clang",
"inherits": ["ci-build", "build-tests", "build-qt", "ci-unix", "ci-clang"],
"inherits": ["ci-build", "build-tests", "build-qt", "build-grpc", "ci-unix", "ci-clang"],
"cacheVariables": {
"RPP_ENABLE_COVERAGE": "ON",
"CMAKE_CXX_FLAGS": "-fprofile-instr-generate -fcoverage-mapping",
Expand All @@ -189,51 +197,51 @@
},
{
"name": "ci-sanitize-asan",
"inherits": ["ci-build", "build-tests", "build-benchmarks", "build-qt", "ci-unix", "ci-clang"],
"inherits": ["ci-build", "build-tests", "build-benchmarks", "build-qt", "build-grpc", "ci-unix", "ci-clang"],
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"
}
},
{
"name": "ci-sanitize-lsan",
"inherits": ["ci-build", "build-tests", "build-benchmarks", "build-qt", "ci-unix", "ci-clang"],
"inherits": ["ci-build", "build-tests", "build-benchmarks", "build-qt", "build-grpc", "ci-unix", "ci-clang"],
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-fsanitize=leak -fno-omit-frame-pointer -g -O1"
}
},
{
"name": "ci-sanitize-msan",
"inherits": ["ci-build", "build-tests", "build-benchmarks", "build-qt", "ci-unix", "ci-clang"],
"inherits": ["ci-build", "build-tests", "build-benchmarks", "build-qt", "build-grpc", "ci-unix", "ci-clang"],
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-fsanitize=memory -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g -O2"
}
},
{
"name": "ci-sanitize-ubsan",
"inherits": ["ci-build", "build-tests", "build-benchmarks", "build-qt", "ci-unix", "ci-clang"],
"inherits": ["ci-build", "build-tests", "build-benchmarks", "build-qt", "build-grpc", "ci-unix", "ci-clang"],
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-fsanitize=undefined"
}
},
{
"name": "ci-macos-tests",
"inherits": ["ci-build", "build-tests", "build-examples", "build-qt", "build-sfml", "ci-unix"]
"inherits": ["ci-build", "build-tests", "build-examples", "build-qt", "build-grpc", "build-sfml", "ci-unix"]
},
{
"name": "ci-ubuntu-clang-tests",
"inherits": ["ci-build", "build-tests", "build-examples", "build-qt", "build-sfml", "ci-unix", "ci-clang", "cppcheck", "clang-tidy"]
"inherits": ["ci-build", "build-tests", "build-examples", "build-qt", "build-grpc", "build-sfml", "ci-unix", "ci-clang", "cppcheck", "clang-tidy"]
},
{
"name": "ci-ubuntu-gcc-tests",
"inherits": ["ci-build", "build-tests", "build-examples", "build-qt", "build-sfml", "ci-unix", "ci-gcc", "cppcheck", "clang-tidy"]
"inherits": ["ci-build", "build-tests", "build-examples", "build-qt", "build-grpc", "build-sfml", "ci-unix", "ci-gcc", "cppcheck", "clang-tidy"]
},
{
"name": "ci-windows-tests",
"inherits": ["ci-build", "build-tests", "build-examples", "build-qt", "build-sfml", "ci-win64"]
"inherits": ["ci-build", "build-tests", "build-examples", "build-qt", "build-grpc", "build-sfml", "ci-win64"]
},
{
"name": "ci-ubuntu-clang-tests-no-checks",
"inherits": ["ci-build", "build-tests", "build-examples", "build-qt", "build-sfml", "ci-unix", "ci-clang" ]
"inherits": ["ci-build", "build-tests", "build-examples", "build-qt", "build-grpc", "build-sfml", "ci-unix", "ci-clang" ]
},


Expand Down
4 changes: 3 additions & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ INPUT = src/rpp \
src/extensions \
src/examples/rpp/doxygen \
src/examples/rppqt/doxygen \
src/examples/rppgrpc/doxygen \
docs

# This tag can be used to specify the character encoding of the source files
Expand Down Expand Up @@ -1078,7 +1079,8 @@ EXCLUDE_SYMBOLS =
# command).

EXAMPLE_PATH = src/examples/rpp/doxygen \
src/examples/rppqt/doxygen
src/examples/rppqt/doxygen \
src/examples/rppgrpc/doxygen

# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
Expand Down
82 changes: 60 additions & 22 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@ macro(rpp_handle_3rdparty TARGET_NAME)
set_target_properties(${TARGET_NAME} PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:${TARGET_NAME},INTERFACE_INCLUDE_DIRECTORIES>)
endmacro()

macro(rpp_fetch_library_extended NAME URL TAG TARGET_NAME)
Include(FetchContent)
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build SHARED libraries")

Set(FETCHCONTENT_QUIET FALSE)

FetchContent_Declare(
${NAME}
GIT_REPOSITORY ${URL}
GIT_TAG ${TAG}
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
GIT_SUBMODULES ""
)

FetchContent_MakeAvailable(${NAME})
rpp_handle_3rdparty(${TARGET_NAME})
endmacro()

macro(rpp_fetch_library NAME URL TAG)
find_package(${NAME} QUIET)
if (NOT ${NAME}_FOUND)
message("-- RPP: Fetching ${NAME}...")
rpp_fetch_library_extended(${NAME} ${URL} ${TAG} ${NAME})
endif()
endmacro()

# ===================== SFML =======================
if (RPP_BUILD_SFML_CODE AND RPP_BUILD_EXAMPLES)
find_package(SFML COMPONENTS graphics system window REQUIRED)
Expand Down Expand Up @@ -42,32 +69,43 @@ if (RPP_BUILD_QT_CODE AND (RPP_BUILD_TESTS OR RPP_BUILD_EXAMPLES))
endmacro()
endif()

macro(rpp_fetch_library_extended NAME URL TAG TARGET_NAME)
Include(FetchContent)
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build SHARED libraries")
# ========================== GRPC ====================================
if (RPP_BUILD_GRPC_CODE AND (RPP_BUILD_TESTS OR RPP_BUILD_EXAMPLES))
find_package(Protobuf CONFIG REQUIRED)
find_package(gRPC CONFIG REQUIRED)

Set(FETCHCONTENT_QUIET FALSE)
rpp_handle_3rdparty(gRPC::grpc++)
rpp_handle_3rdparty(protobuf::protobuf)

FetchContent_Declare(
${NAME}
GIT_REPOSITORY ${URL}
GIT_TAG ${TAG}
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
GIT_SUBMODULES ""
)
macro(rpp_add_proto_target TARGET FILES)
add_library(${TARGET} STATIC ${FILES})

FetchContent_MakeAvailable(${NAME})
rpp_handle_3rdparty(${TARGET_NAME})
endmacro()
target_link_libraries(${TARGET}
PUBLIC
gRPC::grpc++
protobuf::libprotobuf
${grpc_LIBRARIES_TARGETS}
)

macro(rpp_fetch_library NAME URL TAG)
find_package(${NAME} QUIET)
if (NOT ${NAME}_FOUND)
message("-- RPP: Fetching ${NAME} from ${URL} by ${TAG}...")
rpp_fetch_library_extended(${NAME} ${URL} ${TAG} ${NAME})
endif()
endmacro()
target_include_directories(${TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

get_target_property(grpc_cpp_plugin_location gRPC::grpc_cpp_plugin LOCATION )
protobuf_generate(TARGET ${TARGET} OUT_VAR PROTO_FILES LANGUAGE cpp )

protobuf_generate(
TARGET ${TARGET}
LANGUAGE grpc
OUT_VAR GRPC_PROTO_FILES
# PROTOC_OUT_DIR "${PROTO_BINARY_DIR}"
PLUGIN protoc-gen-grpc=${grpc_cpp_plugin_location}
GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc)


set_target_properties(${TARGET} PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:${TARGET},INTERFACE_INCLUDE_DIRECTORIES>)
set_target_properties(${TARGET} PROPERTIES CXX_CLANG_TIDY "")
set_target_properties(${TARGET} PROPERTIES CXX_CPPCHECK "")
endmacro()
endif()

# ==================== RXCPP =======================
if (RPP_BUILD_RXCPP AND RPP_BUILD_BENCHMARKS)
Expand Down
6 changes: 6 additions & 0 deletions cmake/install-rules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ install(
DIRECTORY
src/rpp
src/extensions/rppqt
src/extensions/rppgrpc
DESTINATION
"${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT
Expand All @@ -25,6 +26,11 @@ install(
EXPORT RPPTargets
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rppqt"
)
install(
TARGETS rppgrpc
EXPORT RPPTargets
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rppgrpc"
)

write_basic_package_version_file(
"${package}ConfigVersion.cmake"
Expand Down
4 changes: 4 additions & 0 deletions cmake/variables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ endfunction()
# ------------ Options to tweak ---------------------
option(RPP_BUILD_SFML_CODE "Enable SFML support in examples/code." OFF)
option(RPP_BUILD_QT_CODE "Enable QT support in examples/code." OFF)
option(RPP_BUILD_GRPC_CODE "Enable grpc++ support in examples/code." OFF)

if (RPP_DEVELOPER_MODE)
option(RPP_BUILD_TESTS "Build unit tests tree." OFF)
Expand All @@ -100,6 +101,9 @@ if (RPP_DEVELOPER_MODE)
if (RPP_BUILD_BENCHMARKS)
set(CONAN_ARGS "${CONAN_ARGS};-o rpp/*:with_benchmarks=True")
endif()
if (RPP_BUILD_GRPC_CODE)
set(CONAN_ARGS "${CONAN_ARGS};-o rpp/*:with_grpc=True")
endif()
endif()

if(RPP_ENABLE_COVERAGE)
Expand Down
8 changes: 4 additions & 4 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def requirements(self):
if self.options.with_sfml:
self.requires("sfml/2.6.1", options={"audio": False})

# if self.options.with_grpc:
# self.requires("grpc/1.54.3", transitive_libs=True, transitive_headers=True)
# self.requires("protobuf/3.21.12")
# self.requires("libmount/2.39", override=True)
if self.options.with_grpc:
self.requires("grpc/1.54.3", transitive_libs=True, transitive_headers=True)
self.requires("protobuf/3.21.12")
self.requires("libmount/2.39", override=True)

if self.options.with_cmake:
self.tool_requires("cmake/3.29.3")
4 changes: 4 additions & 0 deletions src/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ add_subdirectory(rpp)
if(RPP_BUILD_QT_CODE)
add_subdirectory(rppqt)
endif()

if (RPP_BUILD_GRPC_CODE)
add_subdirectory(rppgrpc)
endif()
2 changes: 2 additions & 0 deletions src/examples/rppgrpc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# add_subdirectory(communication)
add_subdirectory(doxygen)
9 changes: 9 additions & 0 deletions src/examples/rppgrpc/communication/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(TARGET rppgrpc_communication)

rpp_add_proto_target(${TARGET}_proto protocol.proto)

add_executable(${TARGET}_server server.cpp)
target_link_libraries(${TARGET}_server PRIVATE ${TARGET}_proto rppgrpc)

add_executable(${TARGET}_client client.cpp)
target_link_libraries(${TARGET}_client PRIVATE ${TARGET}_proto rppgrpc)
78 changes: 78 additions & 0 deletions src/examples/rppgrpc/communication/client.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#include <rpp/rpp.hpp>

#include <grpc++/create_channel.h>
#include <rppgrpc/rppgrpc.hpp>

#include "protocol.grpc.pb.h"
#include "protocol.pb.h"


int main()
{
auto channel = grpc::CreateChannel("localhost:50051", grpc::InsecureChannelCredentials());
if (!channel)
{
std::cout << "NO CHANNEL" << std::endl;
return 0;
}
auto stub = TestService::NewStub(channel);
if (!stub)
{
std::cout << "NO STUB" << std::endl;
return 0;
}

std::array<grpc::ClientContext, 3> ctx{};
auto d = rpp::composite_disposable_wrapper::make();

rpp::subjects::publish_subject<std::string> bidi_requests{};
rpp::subjects::publish_subject<Response> bidi_responses{};
bidi_responses.get_observable().subscribe(d, [](const Response& v) {
std::cout << "[BidireactionalResponse]: " << v.ShortDebugString() << std::endl;
});

rppgrpc::add_client_reactor(&TestService::StubInterface::async_interface::Bidirectional,
*stub->async(),
&ctx[0],
bidi_requests.get_observable()
| rpp::ops::take_while([](const std::string& v) { return v != "0"; })
| rpp::ops::map([](const std::string& v) {
Request i{};
i.set_value(std::string{"BidiRequest "} + v);
return i;
}),
bidi_responses.get_observer());

rppgrpc::add_client_reactor(&TestService::StubInterface::async_interface::ClientSide,
*stub->async(),
&ctx[1],
bidi_responses.get_observable()
| rpp::ops::map([](const Response& response) {
Request request{};
request.set_value(std::string{"ClientSideRequest "} + response.value());
return request;
}),
rpp::make_lambda_observer(d, [](const Response& v) {
std::cout << "[ClientsideResponse]: " << v.ShortDebugString() << std::endl;
}));
Request req{};
rppgrpc::add_client_reactor(&TestService::StubInterface::async_interface::ServerSide,
*stub->async(),
&ctx[2],
&req,
rpp::make_lambda_observer(d, [](const Response& v) {
std::cout << "[ServerSideResponse]: " << v.ShortDebugString() << std::endl;
}));

std::cout << "SUBSCRIBED" << std::endl;

std::string in{};
while (!d.is_disposed())
{
std::getline(std::cin, in);
bidi_requests.get_observer().on_next(in);
in.clear();
}

return 0;
}
15 changes: 15 additions & 0 deletions src/examples/rppgrpc/communication/protocol.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";

message Request {
string Value = 1;
}

message Response {
string Value = 1;
}

service TestService {
rpc ServerSide(Request) returns (stream Response) {}
rpc ClientSide(stream Request) returns (Response) {}
rpc Bidirectional(stream Request) returns (stream Response) {}
}
Loading

1 comment on commit 973c278

@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
Subscribe empty callbacks to empty observable 303.81 ns 2.43 ns 2.17 ns 1.12
Subscribe empty callbacks to empty observable via pipe operator 300.83 ns 2.16 ns 2.16 ns 1.00

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 691.92 ns 0.31 ns 0.31 ns 1.00
from array of 1 - create + subscribe + current_thread 1025.67 ns 3.71 ns 3.70 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 2220.16 ns 115.27 ns 127.85 ns 0.90
defer from array of 1 - defer + create + subscribe + immediate 732.68 ns 0.31 ns 0.31 ns 1.00
interval - interval + take(3) + subscribe + immediate 2145.54 ns 59.41 ns 59.19 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3055.24 ns 32.49 ns 32.40 ns 1.00
from array of 1 - create + as_blocking + subscribe + new_thread 30745.93 ns 29824.39 ns 29409.08 ns 1.01
from array of 1000 - create + as_blocking + subscribe + new_thread 42634.15 ns 54677.82 ns 52331.52 ns 1.04
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 3466.74 ns 139.58 ns 151.32 ns 0.92

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1081.22 ns 0.31 ns 0.31 ns 1.00
immediate_just+filter(true)+subscribe 900.61 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 1013.78 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 859.14 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+first()+subscribe 1251.16 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+last()+subscribe 909.27 ns 0.31 ns 0.31 ns 1.00
immediate_just+take_last(1)+subscribe 1123.09 ns 18.39 ns 18.20 ns 1.01

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 287.97 ns 2.16 ns 2.18 ns 0.99
current_thread scheduler create worker + schedule 366.72 ns 6.19 ns 6.17 ns 1.00
current_thread scheduler create worker + schedule + recursive schedule 823.54 ns 56.01 ns 58.64 ns 0.96

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 917.73 ns 0.31 ns 0.31 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 899.22 ns 0.31 ns 0.31 ns 1.00
immediate_just+flat_map(immediate_just(v*2))+subscribe 2360.77 ns 156.07 ns 163.65 ns 0.95
immediate_just+buffer(2)+subscribe 1505.66 ns 13.58 ns 13.58 ns 1.00
immediate_just+window(2)+subscribe + subscsribe inner 2395.89 ns 1078.77 ns 1080.03 ns 1.00

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 824.79 ns - - 0.00
immediate_just+take_while(true)+subscribe 895.87 ns 0.31 ns 0.31 ns 1.00

Utility Operators

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

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 3448.85 ns 172.85 ns 173.86 ns 0.99
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3618.24 ns 168.93 ns 166.69 ns 1.01
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 155.33 ns 129.04 ns 1.20
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 3549.33 ns 933.04 ns 1005.48 ns 0.93
immediate_just(1) + zip(immediate_just(2)) + subscribe 2118.22 ns 198.18 ns 211.72 ns 0.94

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 34.49 ns 14.65 ns 14.77 ns 0.99
subscribe 100 observers to publish_subject 198508.40 ns 14786.06 ns 16386.17 ns 0.90
100 on_next to 100 observers to publish_subject 27152.57 ns 17193.67 ns 17168.30 ns 1.00

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1401.20 ns 13.27 ns 13.27 ns 1.00
basic sample with immediate scheduler 1376.40 ns 5.55 ns 5.55 ns 1.00

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 916.30 ns 0.31 ns 0.31 ns 1.01

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 2085.50 ns 988.81 ns 984.85 ns 1.00

ci-macos

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 968.70 ns 3.89 ns 3.96 ns 0.98
Subscribe empty callbacks to empty observable via pipe operator 968.98 ns 3.91 ns 5.22 ns 0.75

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 1920.83 ns 0.23 ns 0.51 ns 0.46
from array of 1 - create + subscribe + current_thread 2437.20 ns 32.64 ns 39.54 ns 0.83
concat_as_source of just(1 immediate) create + subscribe 5373.45 ns 336.10 ns 461.87 ns 0.73
defer from array of 1 - defer + create + subscribe + immediate 1963.48 ns 0.23 ns 0.51 ns 0.46
interval - interval + take(3) + subscribe + immediate 4963.87 ns 114.30 ns 146.19 ns 0.78
interval - interval + take(3) + subscribe + current_thread 7787.76 ns 118.04 ns 110.55 ns 1.07
from array of 1 - create + as_blocking + subscribe + new_thread 84607.15 ns 82217.85 ns 93640.92 ns 0.88
from array of 1000 - create + as_blocking + subscribe + new_thread 86883.92 ns 84889.46 ns 101866.00 ns 0.83
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 8171.22 ns 379.37 ns 387.14 ns 0.98

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 2843.04 ns 0.23 ns 0.28 ns 0.83
immediate_just+filter(true)+subscribe 2110.16 ns 0.23 ns 0.25 ns 0.94
immediate_just(1,2)+skip(1)+subscribe 2740.33 ns 0.23 ns 0.25 ns 0.94
immediate_just(1,1,2)+distinct_until_changed()+subscribe 2084.90 ns 0.47 ns 0.49 ns 0.94
immediate_just(1,2)+first()+subscribe 3195.24 ns 0.23 ns 0.51 ns 0.46
immediate_just(1,2)+last()+subscribe 2380.42 ns 0.23 ns 0.51 ns 0.46
immediate_just+take_last(1)+subscribe 3007.44 ns 69.56 ns 128.02 ns 0.54

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 891.58 ns 4.18 ns 6.71 ns 0.62
current_thread scheduler create worker + schedule 1214.43 ns 37.64 ns 47.26 ns 0.80
current_thread scheduler create worker + schedule + recursive schedule 2019.45 ns 204.40 ns 211.42 ns 0.97

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 2117.06 ns 4.20 ns 4.35 ns 0.96
immediate_just+scan(10, std::plus)+subscribe 2336.37 ns 0.47 ns 0.87 ns 0.54
immediate_just+flat_map(immediate_just(v*2))+subscribe 5329.15 ns 402.55 ns 499.47 ns 0.81
immediate_just+buffer(2)+subscribe 2482.55 ns 69.44 ns 111.54 ns 0.62
immediate_just+window(2)+subscribe + subscsribe inner 5362.28 ns 2397.81 ns 2508.37 ns 0.96

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 2104.68 ns - - 0.00
immediate_just+take_while(true)+subscribe 2114.11 ns 0.23 ns 0.24 ns 0.96

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 4922.04 ns 5.13 ns 5.15 ns 1.00

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 7421.44 ns 440.75 ns 654.20 ns 0.67
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 8638.19 ns 441.25 ns 633.26 ns 0.70
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 459.55 ns 666.76 ns 0.69
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 7888.11 ns 1905.60 ns 2340.20 ns 0.81
immediate_just(1) + zip(immediate_just(2)) + subscribe 5122.42 ns 842.30 ns 1108.33 ns 0.76

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 76.97 ns 48.48 ns 51.64 ns 0.94
subscribe 100 observers to publish_subject 343937.67 ns 40533.32 ns 43133.37 ns 0.94
100 on_next to 100 observers to publish_subject 53376.21 ns 18568.69 ns 19649.03 ns 0.95

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 2751.81 ns 67.87 ns 71.66 ns 0.95
basic sample with immediate scheduler 2743.55 ns 18.65 ns 19.19 ns 0.97

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 2382.83 ns 0.23 ns 0.25 ns 0.95

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 6568.32 ns 4080.09 ns 4387.47 ns 0.93

ci-ubuntu-clang

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 269.53 ns 0.88 ns 0.88 ns 1.00
Subscribe empty callbacks to empty observable via pipe operator 272.91 ns 0.88 ns 0.88 ns 1.00

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 564.39 ns 0.31 ns 0.31 ns 1.00
from array of 1 - create + subscribe + current_thread 805.28 ns 4.32 ns 4.32 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 2389.92 ns 135.66 ns 135.64 ns 1.00
defer from array of 1 - defer + create + subscribe + immediate 780.71 ns 0.31 ns 0.31 ns 1.00
interval - interval + take(3) + subscribe + immediate 2248.10 ns 58.31 ns 58.26 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3301.34 ns 30.88 ns 30.86 ns 1.00
from array of 1 - create + as_blocking + subscribe + new_thread 30077.74 ns 28193.51 ns 28036.07 ns 1.01
from array of 1000 - create + as_blocking + subscribe + new_thread 39790.19 ns 37233.79 ns 35753.89 ns 1.04
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 3691.96 ns 159.04 ns 158.87 ns 1.00

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1139.79 ns 0.31 ns 0.31 ns 1.00
immediate_just+filter(true)+subscribe 847.17 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 1069.42 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 873.54 ns 0.62 ns 0.62 ns 1.00
immediate_just(1,2)+first()+subscribe 1383.94 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+last()+subscribe 1015.84 ns 0.31 ns 0.31 ns 1.00
immediate_just+take_last(1)+subscribe 1188.22 ns 0.31 ns 0.31 ns 1.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 278.77 ns 0.88 ns 0.88 ns 1.00
current_thread scheduler create worker + schedule 388.79 ns 4.63 ns 4.63 ns 1.00
current_thread scheduler create worker + schedule + recursive schedule 861.19 ns 55.48 ns 55.98 ns 0.99

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 851.18 ns 0.31 ns 0.31 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 966.89 ns 0.31 ns 0.31 ns 1.00
immediate_just+flat_map(immediate_just(v*2))+subscribe 2281.75 ns 137.17 ns 146.90 ns 0.93
immediate_just+buffer(2)+subscribe 1510.32 ns 13.88 ns 13.89 ns 1.00
immediate_just+window(2)+subscribe + subscsribe inner 2446.15 ns 942.48 ns 926.07 ns 1.02

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 829.52 ns - - 0.00
immediate_just+take_while(true)+subscribe 841.86 ns 0.31 ns 0.31 ns 1.00

Utility Operators

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

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 3327.10 ns 161.21 ns 161.51 ns 1.00
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3771.57 ns 146.90 ns 146.20 ns 1.00
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 143.54 ns 143.45 ns 1.00
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 3385.60 ns 849.40 ns 843.59 ns 1.01
immediate_just(1) + zip(immediate_just(2)) + subscribe 2347.21 ns 203.90 ns 208.42 ns 0.98

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 52.19 ns 17.84 ns 17.70 ns 1.01
subscribe 100 observers to publish_subject 210624.00 ns 16154.30 ns 16051.23 ns 1.01
100 on_next to 100 observers to publish_subject 42738.44 ns 20554.24 ns 20971.61 ns 0.98

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1327.39 ns 12.04 ns 12.04 ns 1.00
basic sample with immediate scheduler 1310.73 ns 5.86 ns 5.86 ns 1.00

Aggregating Operators

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

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 2167.14 ns 1218.76 ns 1214.29 ns 1.00

ci-windows

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 559.98 ns 4.01 ns 4.94 ns 0.81
Subscribe empty callbacks to empty observable via pipe operator 580.88 ns 4.01 ns 4.94 ns 0.81

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 1140.83 ns 5.86 ns 5.86 ns 1.00
from array of 1 - create + subscribe + current_thread 1413.31 ns 15.12 ns 15.13 ns 1.00
concat_as_source of just(1 immediate) create + subscribe 3736.19 ns 175.99 ns 174.35 ns 1.01
defer from array of 1 - defer + create + subscribe + immediate 1177.66 ns 5.86 ns 5.86 ns 1.00
interval - interval + take(3) + subscribe + immediate 3368.62 ns 133.45 ns 133.32 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3398.70 ns 52.47 ns 52.96 ns 0.99
from array of 1 - create + as_blocking + subscribe + new_thread 122000.00 ns 118077.78 ns 114275.00 ns 1.03
from array of 1000 - create + as_blocking + subscribe + new_thread 131500.00 ns 134437.50 ns 130800.00 ns 1.03
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 5274.07 ns 209.76 ns 204.97 ns 1.02

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1811.95 ns 12.87 ns 12.88 ns 1.00
immediate_just+filter(true)+subscribe 1307.65 ns 11.66 ns 12.35 ns 0.94
immediate_just(1,2)+skip(1)+subscribe 1970.69 ns 12.98 ns 13.01 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 1335.63 ns 15.85 ns 15.95 ns 0.99
immediate_just(1,2)+first()+subscribe 2015.16 ns 12.63 ns 12.96 ns 0.97
immediate_just(1,2)+last()+subscribe 1785.92 ns 14.13 ns 13.61 ns 1.04
immediate_just+take_last(1)+subscribe 2002.12 ns 60.72 ns 59.61 ns 1.02

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 478.33 ns 6.17 ns 6.17 ns 1.00
current_thread scheduler create worker + schedule 649.94 ns 13.96 ns 14.51 ns 0.96
current_thread scheduler create worker + schedule + recursive schedule 1350.13 ns 107.41 ns 107.19 ns 1.00

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 1302.75 ns 11.41 ns 12.26 ns 0.93
immediate_just+scan(10, std::plus)+subscribe 1416.05 ns 21.27 ns 21.58 ns 0.99
immediate_just+flat_map(immediate_just(v*2))+subscribe 3455.78 ns 200.55 ns 202.25 ns 0.99
immediate_just+buffer(2)+subscribe 2620.64 ns 60.21 ns 59.26 ns 1.02
immediate_just+window(2)+subscribe + subscsribe inner 3974.62 ns 1275.19 ns 1273.07 ns 1.00

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 1608.47 ns 11.41 ns 11.41 ns 1.00
immediate_just+take_while(true)+subscribe 1312.23 ns 11.65 ns 12.37 ns 0.94

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 3083.38 ns 8.02 ns 8.02 ns 1.00

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 5100.00 ns 210.59 ns 210.48 ns 1.00
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 5440.11 ns 214.52 ns 219.58 ns 0.98
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 197.10 ns 198.12 ns 0.99
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 5391.19 ns 940.06 ns 926.07 ns 1.02
immediate_just(1) + zip(immediate_just(2)) + subscribe 3526.85 ns 536.09 ns 527.20 ns 1.02

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 36.46 ns 20.06 ns 20.11 ns 1.00
subscribe 100 observers to publish_subject 256325.00 ns 29489.19 ns 29048.57 ns 1.02
100 on_next to 100 observers to publish_subject 51935.00 ns 32623.33 ns 32648.57 ns 1.00

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1846.99 ns 57.00 ns 57.59 ns 0.99
basic sample with immediate scheduler 1877.35 ns 38.25 ns 38.25 ns 1.00

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 1448.24 ns 19.98 ns 19.98 ns 1.00

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 1882.87 ns 333.83 ns 340.46 ns 0.98

Please sign in to comment.