Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "sample_with_time" operator #280

Merged
merged 8 commits into from
Oct 11, 2022
Merged

Add "sample_with_time" operator #280

merged 8 commits into from
Oct 11, 2022

Conversation

victimsnino
Copy link
Owner

Partly resolves #265

@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Merging #280 (9f9b3e5) into main (189556d) will increase coverage by 0.10%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #280      +/-   ##
==========================================
+ Coverage   98.59%   98.69%   +0.10%     
==========================================
  Files         100      102       +2     
  Lines        1419     1455      +36     
==========================================
+ Hits         1399     1436      +37     
+ Misses         20       19       -1     
Impacted Files Coverage Δ
src/rpp/rpp/observables/interface_observable.hpp 100.00% <ø> (ø)
src/rpp/rpp/operators/delay.hpp 100.00% <100.00%> (ø)
src/rpp/rpp/operators/fwd/sample.hpp 100.00% <100.00%> (ø)
src/rpp/rpp/operators/sample.hpp 100.00% <100.00%> (ø)
src/rpp/rpp/utils/spinlock.hpp 100.00% <100.00%> (ø)
src/rpp/rpp/operators/fwd/do.hpp 100.00% <0.00%> (ø)
src/rpp/rpp/subscribers/specific_subscriber.hpp 100.00% <0.00%> (+3.03%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ clang-tidy found issue(s) with the introduced code (1/1)

{
if (i == 30u)
{
std::this_thread::yield();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ clang-diagnostic-error ⚠️
no member named this_thread in namespace std

@github-actions
Copy link
Contributor

github-actions bot commented Oct 11, 2022

BENCHMARK RESULTS (AUTOGENERATED)

ci-ubuntu-clang

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 0.41ns 0.334921 1.21 0.40ns
Dynamic observable construction 35.09ns 29.1563 1.20 29.91ns
Specific observable construction + as_dynamic 34.96ns 29.1713 1.20 29.87ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 135.39ns 110.646 1.22 362.93ns
Specific observable lift dynamic observer 161.33ns 136.659 1.18 374.01ns
Dynamic observable lift specific observer 222.34ns 183.591 1.21 404.68ns
Dynamic observable lift dynamic observer 229.12ns 193.106 1.19 401.23ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 92.83ns 77.3627 1.20 347.42ns
Specific observable subscribe dynamic observer 113.80ns 88.1158 1.29 358.26ns
Dynamic observable subscribe specific observer 177.30ns 145.706 1.22 405.60ns
Dynamic observable subscribe dynamic observer 168.01ns 146.309 1.15 380.89ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 91.76ns 77.226 1.19 347.24ns
Dynamic observable subscribe lambda 170.57ns 139.726 1.22 399.01ns
Specific observable subscribe lambda without subscription 91.76ns 76.6846 1.20 345.78ns
Dynamic observable subscribe lambda without subscription 167.90ns 139.878 1.20 400.58ns
Specific observable subscribe specific subscriber 51.75ns 43.1564 1.20 275.97ns
Dynamic observable subscribe specific subscriber 128.89ns 105.529 1.22 325.10ns
Specific observable subscribe dynamic observer 52.30ns 43.5231 1.20 295.38ns
Dynamic observable subscribe dynamic observer 113.30ns 96.5721 1.17 316.25ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.40ns 0.335324 1.20 0.40ns
Dynamic observer construction 35.04ns 29.2113 1.20 25.57ns
Specific observer construction + as_dynamic 35.11ns 32.1472 1.09 25.30ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.80ns 0.670109 1.20 0.80ns
Dynamic observer OnNext 2.01ns 1.67707 1.20 2.81ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 40.83ns 33.8217 1.21 77.61ns
Make copy of subscriber 20.05ns 16.7365 1.20 5.67ns
Transform subsriber to dynamic 52.65ns 45.8691 1.15 31.43ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 40.63ns 33.8351 1.20 61.52ns
composite_subscription add 59.23ns 49.8789 1.19 112.46ns
composite_subscription unsubscribe 53.04ns 43.3373 1.22 28.17ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 320.63ns 269.458 1.19 2578.38ns
sending of values from observable via buffer to subscriber 7.75ns 6.39567 1.21 32.82ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 332.14ns 270.958 1.23 609.73ns
long stateful chain creation + subscribe 477.86ns 399.565 1.20 958.36ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 1066.54ns 900.81 1.18 1063.81ns
sending of values from observable via combine_latest to subscriber 32.99ns 27.5941 1.20 4.07ns

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 2260.46ns 1890.77 1.20 3604.63ns
concat_with 2632.45ns 2220.38 1.19 4005.26ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 153.09ns 129.04 1.19 305.58ns
sending of values from observable via distinct_until_changed to subscriber 2.81ns 2.6825 1.05 1.61ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 172.16ns 143.026 1.20 696.10ns
sending of values from observable via first to subscriber 0.81ns 0.671155 1.20 0.81ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 100.97ns 84.8463 1.19 748.05ns
error 160.73ns 135.854 1.18 888.08ns
never 56.47ns 46.8708 1.20 305.61ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 118.85ns 100.896 1.18 793.22ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 1.61ns 0.671499 2.39 134.85ns
re-schedule 10 times 13.86ns 6.85085 2.02 172.28ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 103.06ns 87.7848 1.17 770.53ns
just send variadic 140.31ns 115.935 1.21 888.73ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 224.62ns 186.015 1.21 431.64ns
sending of values from observable via last to subscriber 3.07ns 2.38304 1.29 2.01ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 106.88ns 89.0219 1.20 291.76ns
sending of values from observable via map to subscriber 1.21ns 1.00512 1.20 2.82ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 2208.43ns 1859.9 1.19 3609.73ns
merge_with 2569.16ns 2190.53 1.17 3851.03ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 547.24ns 555.964 0.98 3010.56ns
sending of values from observable via observe_on to subscriber 77.53ns 89.9299 0.86 233.24ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 28.95ns 24.1116 1.20 13.45ns
on_error 0.81ns 0.67385 1.20 23.08ns
on_completed 0.81ns 0.67329 1.20 0.81ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 233.43ns 196.602 1.19 226.10ns
get_observable 31.75ns 29.1172 1.09 60.46ns
get_subscriber 72.69ns 60.5412 1.20 16.66ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 4719.16ns 3966.93 1.19 3208.36ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 153.56ns 125.401 1.22 360.29ns
sending of values from observable via scan to subscriber 2.41ns 2.21532 1.09 2.81ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 2.42ns 2.02084 1.20 .
mutex lock increment 21.72ns 18.083 1.20 .
spin-lock increment 10.85ns 9.02793 1.20 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 151.46ns 118.429 1.28 554.79ns
sending of values from observable via skip to subscriber 2.81ns 2.00736 1.40 2.41ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 2665.02ns 2224.33 1.20 3292.47ns
sending of values from observable via switch_on_next to subscriber 678.53ns 568.818 1.19 762.35ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 222.40ns 186.177 1.19 597.00ns
sending of values from observable via take to subscriber 2.82ns 2.34854 1.20 3.20ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 272.53ns 230.401 1.18 635.67ns
sending of values from observable via take_last to subscriber 4.43ns 2.91072 1.52 4.21ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 1260.77ns 1056.46 1.19 1394.51ns
sending of values from observable via take_until to subscriber 10.85ns 9.03398 1.20 2.14ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 15.88ns 11.7398 1.35 190.80ns
re-schedule 10 times 41.48ns 30.7688 1.35 230.29ns
recursively schedule 10 times 1690.79ns 1388.93 1.22 6706.22ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 2428.35ns 2024.02 1.20 4024.33ns
sending of values from observable via window to subscriber 657.31ns 547.043 1.20 445.04ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 1250.65ns 1041.47 1.20 1273.76ns
sending of values from observable via with_latest_from to subscriber 32.08ns 26.3982 1.22 4.36ns

ci-ubuntu-gcc

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 0.34ns 0.335034 1.01 0.40ns
Dynamic observable construction 29.95ns 31.636 0.95 27.38ns
Specific observable construction + as_dynamic 29.86ns 31.7026 0.94 30.32ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 138.89ns 119.105 1.17 430.03ns
Specific observable lift dynamic observer 172.07ns 145.419 1.18 432.54ns
Dynamic observable lift specific observer 240.50ns 198.579 1.21 482.82ns
Dynamic observable lift dynamic observer 256.38ns 207.968 1.23 466.32ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 100.42ns 82.8207 1.21 413.83ns
Specific observable subscribe dynamic observer 111.78ns 95.2686 1.17 404.79ns
Dynamic observable subscribe specific observer 175.28ns 150.017 1.17 454.57ns
Dynamic observable subscribe dynamic observer 173.74ns 146.119 1.19 457.41ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 99.53ns 83.3529 1.19 392.15ns
Dynamic observable subscribe lambda 190.26ns 151.264 1.26 458.57ns
Specific observable subscribe lambda without subscription 93.78ns 83.4772 1.12 408.42ns
Dynamic observable subscribe lambda without subscription 178.07ns 151.027 1.18 458.98ns
Specific observable subscribe specific subscriber 65.59ns 50.275 1.30 385.40ns
Dynamic observable subscribe specific subscriber 135.07ns 118.353 1.14 388.83ns
Specific observable subscribe dynamic observer 53.87ns 50.2178 1.07 348.24ns
Dynamic observable subscribe dynamic observer 102.23ns 102.295 1.00 415.60ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 0.40ns 0.335394 1.19 0.39ns
Dynamic observer construction 34.11ns 31.4404 1.08 22.57ns
Specific observer construction + as_dynamic 34.04ns 31.4988 1.08 24.28ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.43ns 0.334704 1.29 0.40ns
Dynamic observer OnNext 2.11ns 1.67337 1.26 2.35ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 35.57ns 34.7182 1.02 85.12ns
Make copy of subscriber 20.45ns 16.7153 1.22 5.54ns
Transform subsriber to dynamic 41.04ns 45.1039 0.91 27.52ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 41.50ns 36.8832 1.13 70.75ns
composite_subscription add 56.95ns 47.4435 1.20 97.16ns
composite_subscription unsubscribe 52.46ns 41.5898 1.26 22.00ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 308.86ns 264.977 1.17 2378.41ns
sending of values from observable via buffer to subscriber 7.98ns 7.40594 1.08 35.76ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 408.30ns 301.772 1.35 846.47ns
long stateful chain creation + subscribe 646.43ns 433.383 1.49 1349.55ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 965.77ns 950.941 1.02 1360.26ns
sending of values from observable via combine_latest to subscriber 27.10ns 27.4717 0.99 1.89ns

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 2349.94ns 1943.77 1.21 4547.02ns
concat_with 2833.44ns 2292.02 1.24 4905.31ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 129.25ns 137.648 0.94 453.69ns
sending of values from observable via distinct_until_changed to subscriber 3.71ns 3.88076 0.96 1.35ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 191.50ns 161.953 1.18 940.90ns
sending of values from observable via first to subscriber 0.83ns 1.33973 0.62 0.58ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 104.12ns 94.3631 1.10 798.11ns
error 162.93ns 136.101 1.20 1192.41ns
never 61.63ns 49.503 1.25 350.35ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 131.47ns 105.99 1.24 951.43ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 1.13ns 1.76168 0.64 166.21ns
re-schedule 10 times 22.15ns 22.8406 0.97 231.09ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 110.64ns 91.6615 1.21 970.12ns
just send variadic 159.79ns 128.057 1.25 1040.01ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 242.00ns 196.281 1.23 542.46ns
sending of values from observable via last to subscriber 3.15ns 2.09461 1.50 1.57ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 129.32ns 100.95 1.28 430.96ns
sending of values from observable via map to subscriber 1.05ns 1.34029 0.78 2.38ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 2297.44ns 1893.27 1.21 4632.77ns
merge_with 2746.01ns 2258.24 1.22 5116.31ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 581.78ns 581.224 1.00 3365.02ns
sending of values from observable via observe_on to subscriber 75.60ns 87.6181 0.86 297.03ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 29.42ns 22.5865 1.30 12.09ns
on_error 0.80ns 0.673725 1.19 20.48ns
on_completed 0.79ns 1.34669 0.58 0.78ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 246.50ns 208.48 1.18 214.45ns
get_observable 35.54ns 29.4658 1.21 53.04ns
get_subscriber 70.05ns 57.8157 1.21 27.40ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 4996.60ns 4152.29 1.20 3871.80ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 154.11ns 137.336 1.12 464.76ns
sending of values from observable via scan to subscriber 3.16ns 3.01519 1.05 1.86ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 2.70ns 2.00521 1.34 .
mutex lock increment 22.08ns 18.059 1.22 .
spin-lock increment 13.87ns 9.0274 1.54 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 192.46ns 134.244 1.43 652.66ns
sending of values from observable via skip to subscriber 3.69ns 4.10296 0.90 2.35ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 2869.60ns 2385.44 1.20 5321.36ns
sending of values from observable via switch_on_next to subscriber 678.45ns 599.786 1.13 1427.93ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 232.73ns 191.293 1.22 756.23ns
sending of values from observable via take to subscriber 5.32ns 4.2377 1.26 3.56ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 329.22ns 232.598 1.42 816.39ns
sending of values from observable via take_last to subscriber 3.74ns 3.73069 1.00 7.15ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 1443.34ns 1082.23 1.33 1954.45ns
sending of values from observable via take_until to subscriber 11.64ns 8.70725 1.34 2.14ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 26.53ns 21.2879 1.25 211.51ns
re-schedule 10 times 52.64ns 50.0575 1.05 272.80ns
recursively schedule 10 times 1803.23ns 1448.35 1.25 8244.24ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 2713.94ns 2167.52 1.25 4126.35ns
sending of values from observable via window to subscriber 710.42ns 599.466 1.19 552.17ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 1147.39ns 1129.72 1.02 1703.07ns
sending of values from observable via with_latest_from to subscriber 36.04ns 25.4576 1.42 4.28ns

ci-windows

Observable construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable construction 2.01ns 1.32816 1.51 0.80ns
Dynamic observable construction 71.94ns 73.4562 0.98 117.36ns
Specific observable construction + as_dynamic 72.16ns 71.6573 1.01 117.35ns

Observable lift

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable lift specific observer 161.19ns 154.033 1.05 1184.73ns
Specific observable lift dynamic observer 191.15ns 203.597 0.94 1231.71ns
Dynamic observable lift specific observer 275.13ns 303.312 0.91 1356.58ns
Dynamic observable lift dynamic observer 252.26ns 261.229 0.97 1260.15ns

Observable subscribe

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe specific observer 122.83ns 142.76 0.86 1146.91ns
Specific observable subscribe dynamic observer 137.48ns 132.908 1.03 1175.23ns
Dynamic observable subscribe specific observer 230.65ns 262.265 0.88 1317.45ns
Dynamic observable subscribe dynamic observer 189.44ns 203.202 0.93 1227.52ns

Observable subscribe #2

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observable subscribe lambda 120.90ns 123.017 0.98 1145.77ns
Dynamic observable subscribe lambda 230.44ns 258.774 0.89 1316.53ns
Specific observable subscribe lambda without subscription 122.92ns 139.317 0.88 1145.73ns
Dynamic observable subscribe lambda without subscription 226.17ns 228.871 0.99 1315.26ns
Specific observable subscribe specific subscriber 46.78ns 49.4961 0.95 849.55ns
Dynamic observable subscribe specific subscriber 151.26ns 146.271 1.03 1021.96ns
Specific observable subscribe dynamic observer 48.47ns 52.1959 0.93 870.29ns
Dynamic observable subscribe dynamic observer 99.19ns 101.048 0.98 906.07ns

Observer construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer construction 2.01ns 1.50432 1.34 2.00ns
Dynamic observer construction 72.71ns 74.2441 0.98 107.09ns
Specific observer construction + as_dynamic 72.88ns 73.8117 0.99 106.33ns

OnNext

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Specific observer OnNext 0.45ns 0.590402 0.76 0.49ns
Dynamic observer OnNext 2.33ns 1.83602 1.27 2.01ns

Subscriber construction

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
Make subsriber 73.09ns 74.976 0.97 322.81ns
Make copy of subscriber 16.08ns 16.7123 0.96 37.38ns
Transform subsriber to dynamic 86.47ns 97.4492 0.89 143.03ns

Subscription

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
composite_subscription create 74.08ns 75.0721 0.99 313.82ns
composite_subscription add 69.35ns 73.5766 0.94 170.02ns
composite_subscription unsubscribe 62.00ns 72.9193 0.85 114.25ns

buffer

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
buffer 359.72ns 332.578 1.08 4331.00ns
sending of values from observable via buffer to subscriber 6.81ns 5.58678 1.22 85.73ns

chains creation test

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
long non-state chain creation + subscribe 314.45ns 249.761 1.26 1688.87ns
long stateful chain creation + subscribe 679.50ns 690.028 0.98 3242.62ns

combine_latest

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
combine_latest construction from observable via dot + subscribe 1569.93ns 1423.69 1.10 3034.75ns
sending of values from observable via combine_latest to subscriber 46.33ns 39.2172 1.18 3.86ns

concat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
concat 2701.00ns 2658.3 1.02 10685.70ns
concat_with 3465.38ns 3829.88 0.90 11598.30ns

distinct_until_changed

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
distinct_until_changed construction from observable via dot + subscribe 197.94ns 202.368 0.98 1020.40ns
sending of values from observable via distinct_until_changed to subscriber 3.21ns 2.95713 1.09 3.21ns

first

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
first construction from observable via dot + subscribe 156.50ns 148.419 1.05 2649.00ns
sending of values from observable via first to subscriber 2.51ns 2.6991 0.93 1.25ns

foundamental sources

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
empty 82.79ns 83.0847 1.00 2353.45ns
error 147.31ns 139.871 1.05 2492.90ns
never 47.53ns 51.3272 0.93 877.96ns

from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
from vector with int 140.80ns 157.736 0.89 2419.18ns

immediate scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 1.64ns 1.18231 1.39 406.32ns
re-schedule 10 times 130.39ns 87.1019 1.50 433.38ns

just

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
just send int 86.68ns 78.0431 1.11 2370.45ns
just send variadic 122.55ns 128.679 0.95 2450.90ns

last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
last construction from observable via dot + subscribe 237.90ns 243.052 0.98 1435.19ns
sending of values from observable via last to subscriber 3.35ns 3.42731 0.98 3.28ns

map

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
map construction from observable via dot + subscribe 111.59ns 104.817 1.06 985.85ns
sending of values from observable via map to subscriber 3.54ns 3.82695 0.92 7.46ns

merge

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
merge 2640.60ns 2627.82 1.00 10970.00ns
merge_with 3361.25ns 3394.75 0.99 11619.00ns

observe_on

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
observe_on construction from observable via dot + subscribe 635.14ns 679.629 0.93 5933.00ns
sending of values from observable via observe_on to subscriber 62.36ns 74.63 0.84 773.79ns

publish_subject callbacks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
on_next 22.56ns 17.481 1.29 28.32ns
on_error 2.46ns 2.9792 0.83 19.19ns
on_completed 2.96ns 2.37719 1.24 0.81ns

publish_subject routines

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
construct 386.85ns 313.417 1.23 596.84ns
get_observable 31.08ns 25.3574 1.23 154.01ns
get_subscriber 65.22ns 50.1751 1.30 99.34ns

repeat

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
repeat construction from observable via dot + subscribe 5902.60ns 5359.8 1.10 11120.70ns

scan

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
scan construction from observable via dot + subscribe 188.10ns 181.331 1.04 1260.60ns
sending of values from observable via scan to subscriber 5.33ns 5.70211 0.93 8.39ns

single-threaded locks

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no-lock increment 2.78ns 1.65816 1.68 .
mutex lock increment 26.17ns 22.7186 1.15 .
spin-lock increment 10.45ns 9.03552 1.16 .

skip

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
skip construction from observable via dot + subscribe 193.85ns 171.143 1.13 1555.93ns
sending of values from observable via skip to subscriber 3.21ns 4.05978 0.79 3.33ns

switch_on_next

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
switch_on_next construction from observable via dot + subscribe 3476.57ns 3624.62 0.96 12054.00ns
sending of values from observable via switch_on_next to subscriber 840.63ns 756.031 1.11 3072.78ns

take

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take construction from observable via dot + subscribe 245.74ns 249.742 0.98 2140.92ns
sending of values from observable via take to subscriber 6.10ns 4.58538 1.33 5.73ns

take_last

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_last construction from observable via dot + subscribe 330.14ns 346.653 0.95 2399.00ns
sending of values from observable via take_last to subscriber 4.13ns 4.28645 0.96 20.15ns

take_until

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
take_until construction from observable via dot + subscribe 1652.88ns 1741.88 0.95 5250.00ns
sending of values from observable via take_until to subscriber 12.24ns 11.0946 1.10 5.16ns

trampoline scheduler

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
no any re-schedule 18.18ns 16.7895 1.08 590.69ns
re-schedule 10 times 143.55ns 106.761 1.34 623.23ns
recursively schedule 10 times 2513.50ns 2632.82 0.95 19329.50ns

window

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
window 2955.22ns 2955.6 1.00 9550.67ns
sending of values from observable via window to subscriber 823.67ns 828.906 0.99 1582.31ns

with_latest_from

Table
Test Name Current, ns Prev, ns Ratio RxCpp current, ns
with_latest_from construction from observable via dot + subscribe 2065.50ns 1794.0 1.15 3765.83ns
sending of values from observable via with_latest_from to subscriber 35.33ns 33.4084 1.06 6.55ns

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@victimsnino victimsnino merged commit 4c39786 into main Oct 11, 2022
@victimsnino victimsnino deleted the sample branch October 11, 2022 21:13
@thorstink
Copy link
Contributor

Awesome, thanks :-)

@victimsnino
Copy link
Owner Author

@thorstink, waiting for the feedback ;-)
BTW, do you still need sample with observable logic?

@thorstink
Copy link
Contributor

thorstink commented Oct 12, 2022 via email

@victimsnino
Copy link
Owner Author

@thorstink ,

Ah, I think I am missing something. What feedback? :-)

Feedback about usage =) As far as I remember you requested this operator =)

sample_with_time is something I would still like a lot. What I mean is
something similar to RxCpp's sample_with_time:
https://github.com/ReactiveX/RxCpp/blob/main/Rx/v2/test/operators/sample.cpp

Yeah, rpp has same after this PR =)

Something that rxcpp does not have, but what I think would be nice (I've
noticed I wanted it sometimes), is a simple downsample operator. Pass one
message, skip three, pass one, skip three etc.

Does it something like "take N elements each NNth element"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "sample_with_time" operator
2 participants