Skip to content

element_at operator#613

Merged
victimsnino merged 5 commits into
victimsnino:v2from
CorentinBT:element_at
Aug 5, 2024
Merged

element_at operator#613
victimsnino merged 5 commits into
victimsnino:v2from
CorentinBT:element_at

Conversation

@CorentinBT
Copy link
Copy Markdown
Contributor

@CorentinBT CorentinBT commented Aug 3, 2024

Summary by CodeRabbit

  • New Features

    • Introduced the element_at operator, allowing users to retrieve an item at a specified index from a sequence in ReactivePlusPlus.
    • Added a benchmarking section for immediate_just and element_at to enhance testing coverage.
  • Bug Fixes

    • Improved error handling for the element_at operator, ensuring it manages edge cases and empty sequences correctly.
  • Tests

    • Added a comprehensive suite of unit tests for the element_at operator, validating its functionality and performance across various scenarios.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 3, 2024

Walkthrough

Walkthrough

The changes introduce the element_at operator in the ReactivePlusPlus library, allowing access to specific elements from observable sequences by index. This update includes a comprehensive test suite to ensure the operator's reliability across various scenarios. Additionally, improvements to header inclusions enhance functionality and control flow, contributing to a more robust reactive programming experience.

Changes

Files Change Summary
src/benchmarks/benchmarks.cpp Added a benchmarking section for immediate_just and element_at, evaluating behavior with test cases.
src/rpp/rpp/operators.hpp Included element_at.hpp to enhance operator functionality for accessing elements by index.
src/rpp/rpp/operators/element_at.hpp Implemented the element_at operator, managing state and emission of specified indexed elements.
src/rpp/rpp/operators/fwd.hpp Added declaration for new element_at(size_t index) function to the operators namespace.
src/rpp/rpp/operators/publish.hpp Included publish_subject.hpp for enhanced publish-subscribe functionality.
src/tests/rpp/test_element_at.cpp Created a new test suite for element_at, validating functionality across various scenarios, including edge cases.

Sequence Diagram(s)

sequenceDiagram
    participant Observable
    participant ElementAtOperator
    participant Observer

    Observable->>ElementAtOperator: Subscribe(index)
    ElementAtOperator->>Observable: Request item at index
    Observable->>ElementAtOperator: Emit item
    ElementAtOperator->>Observer: Forward item if index matches
    Observable->>Observer: Emit completion or error if end of sequence
Loading

🐇 "In code we find delight,
With element_at, our future's bright!
Observables frolic, values in sight,
Testing ensures our paths are right.
Let's hop along, with joy in flight!" 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f3645df and 1f1051c.

Files selected for processing (6)
  • src/benchmarks/benchmarks.cpp (1 hunks)
  • src/rpp/rpp/operators.hpp (1 hunks)
  • src/rpp/rpp/operators/element_at.hpp (1 hunks)
  • src/rpp/rpp/operators/fwd.hpp (1 hunks)
  • src/rpp/rpp/operators/publish.hpp (1 hunks)
  • src/tests/rpp/test_element_at.cpp (1 hunks)
Additional comments not posted (12)
src/rpp/rpp/operators/publish.hpp (1)

4-4: Approved: Inclusion of necessary header file.

The inclusion of publish_subject.hpp ensures that the publish-subscribe functionality is available within this context.

src/rpp/rpp/operators/element_at.hpp (4)

1-19: Approved: File header and includes.

The file includes standard headers and project-specific headers necessary for the implementation of the element_at operator.


20-57: Approved: element_at_observer_strategy structure.

The structure is well-defined and includes necessary methods for handling next, error, and completed events. The logic for emitting the element at the specified index and handling out-of-bounds errors is correctly implemented.


58-74: Approved: element_at_t structure.

The structure correctly defines the necessary traits and strategies for the element_at operator. The implementation follows the required patterns for lift operators.


77-98: Approved: element_at function.

The function is correctly implemented and provides the element_at operator as an inline function. The documentation and example usage are clear and informative.

src/tests/rpp/test_element_at.cpp (4)

1-22: Approved: File header and includes.

The file includes standard headers and project-specific headers necessary for testing the element_at operator.


23-89: Approved: Test case for emitting element at index.

The test case includes multiple sections to test the element_at operator with different sequences and indices. Each section is well-defined and covers necessary scenarios, including sequences of values, empty sequences, and error sequences. The checks for received values, error counts, and completion counts are correctly implemented.


92-105: Approved: Test case for ensuring no extra copies.

The test case ensures that the element_at operator does not produce extra copies. It is well-defined and correctly checks the copy and move counts.


107-110: Approved: Test case for disposable contracts.

The test case ensures that the element_at operator satisfies disposable contracts. It is well-defined and correctly checks the disposable contracts.

src/rpp/rpp/operators.hpp (1)

52-52: New header inclusion looks good.

The inclusion of <rpp/operators/element_at.hpp> is correctly placed among other filtering operators.

src/rpp/rpp/operators/fwd.hpp (1)

48-48: New function declaration looks good.

The declaration of auto element_at(size_t index); is correctly added to the rpp::operators namespace.

src/benchmarks/benchmarks.cpp (1)

583-597: New benchmarking section looks good.

The new benchmarking section for immediate_just(1,2,3)+element_at(1)+subscribe is correctly implemented and follows the existing code style and conventions.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 3, 2024

BENCHMARK RESULTS (AUTOGENERATED)

ci-ubuntu-gcc

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 303.81 ns 2.16 ns 2.16 ns 1.00
Subscribe empty callbacks to empty observable via pipe operator 308.61 ns 2.16 ns 2.16 ns 1.00

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 702.05 ns 0.31 ns 0.31 ns 1.00
from array of 1 - create + subscribe + current_thread 1045.21 ns 3.43 ns 3.70 ns 0.93
concat_as_source of just(1 immediate) create + subscribe 2305.59 ns 123.49 ns 120.52 ns 1.02
defer from array of 1 - defer + create + subscribe + immediate 763.55 ns 0.31 ns 0.31 ns 1.00
interval - interval + take(3) + subscribe + immediate 2130.04 ns 59.19 ns 59.19 ns 1.00
interval - interval + take(3) + subscribe + current_thread 2984.21 ns 32.46 ns 32.40 ns 1.00
from array of 1 - create + as_blocking + subscribe + new_thread 29216.64 ns 27455.36 ns 28137.95 ns 0.98
from array of 1000 - create + as_blocking + subscribe + new_thread 39474.43 ns 51190.22 ns 52202.10 ns 0.98
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 3566.54 ns 141.80 ns 147.29 ns 0.96

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1081.91 ns 0.31 ns 0.31 ns 1.00
immediate_just+filter(true)+subscribe 877.64 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 995.22 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 842.74 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+first()+subscribe 1224.54 ns 0.62 ns 0.31 ns 2.00
immediate_just(1,2)+last()+subscribe 949.05 ns 0.31 ns 0.31 ns 1.00
immediate_just+take_last(1)+subscribe 1114.10 ns 17.60 ns 17.91 ns 0.98
immediate_just(1,2,3)+element_at(1)+subscribe 829.76 ns 0.31 ns - 0.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 270.72 ns 2.16 ns 2.16 ns 1.00
current_thread scheduler create worker + schedule 399.49 ns 5.87 ns 6.17 ns 0.95
current_thread scheduler create worker + schedule + recursive schedule 863.02 ns 55.99 ns 55.83 ns 1.00

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 856.80 ns 0.31 ns 0.31 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 925.00 ns 0.31 ns 0.31 ns 1.00
immediate_just+flat_map(immediate_just(v*2))+subscribe 2343.00 ns 159.93 ns 169.21 ns 0.95
immediate_just+buffer(2)+subscribe 1557.49 ns 13.90 ns 13.59 ns 1.02
immediate_just+window(2)+subscribe + subscsribe inner 2440.26 ns 1051.05 ns 1067.38 ns 0.98

Conditional Operators

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

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 2063.56 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 3419.50 ns 186.42 ns 173.09 ns 1.08
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3651.71 ns 176.55 ns 179.44 ns 0.98
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 136.64 ns 132.50 ns 1.03
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 3601.67 ns 937.09 ns 1086.59 ns 0.86
immediate_just(1) + zip(immediate_just(2)) + subscribe 2126.69 ns 226.51 ns 225.72 ns 1.00

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 34.43 ns 14.69 ns 14.64 ns 1.00
subscribe 100 observers to publish_subject 200933.80 ns 15260.65 ns 15561.80 ns 0.98
100 on_next to 100 observers to publish_subject 26922.18 ns 17423.74 ns 17113.03 ns 1.02

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1399.47 ns 13.28 ns 13.28 ns 1.00
basic sample with immediate scheduler 1419.56 ns 5.24 ns 5.55 ns 0.95

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 923.04 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 2059.27 ns 976.50 ns 979.48 ns 1.00

ci-macos

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 2117.89 ns 9.43 ns 3.90 ns 2.42
Subscribe empty callbacks to empty observable via pipe operator 1518.97 ns 6.30 ns 3.93 ns 1.60

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 2869.15 ns 0.35 ns 0.23 ns 1.50
from array of 1 - create + subscribe + current_thread 4921.21 ns 51.08 ns 32.29 ns 1.58
concat_as_source of just(1 immediate) create + subscribe 11044.35 ns 498.08 ns 336.26 ns 1.48
defer from array of 1 - defer + create + subscribe + immediate 2951.54 ns 0.39 ns 0.23 ns 1.66
interval - interval + take(3) + subscribe + immediate 10464.79 ns 169.74 ns 114.45 ns 1.48
interval - interval + take(3) + subscribe + current_thread 9030.15 ns 179.22 ns 93.75 ns 1.91
from array of 1 - create + as_blocking + subscribe + new_thread 151496.14 ns 128992.29 ns 82531.23 ns 1.56
from array of 1000 - create + as_blocking + subscribe + new_thread 149431.17 ns 156944.00 ns 85320.17 ns 1.84
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 17685.34 ns 673.86 ns 374.67 ns 1.80

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 5721.11 ns 0.75 ns 0.22 ns 3.45
immediate_just+filter(true)+subscribe 4355.06 ns 0.71 ns 0.22 ns 3.18
immediate_just(1,2)+skip(1)+subscribe 4192.93 ns 0.38 ns 0.22 ns 1.71
immediate_just(1,1,2)+distinct_until_changed()+subscribe 3117.94 ns 0.97 ns 0.45 ns 2.18
immediate_just(1,2)+first()+subscribe 6282.00 ns 0.45 ns 0.22 ns 2.04
immediate_just(1,2)+last()+subscribe 5006.40 ns 0.68 ns 0.22 ns 3.05
immediate_just+take_last(1)+subscribe 6404.23 ns 169.03 ns 67.07 ns 2.52
immediate_just(1,2,3)+element_at(1)+subscribe 4375.50 ns 0.35 ns - 0.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 1283.46 ns 6.38 ns 4.13 ns 1.54
current_thread scheduler create worker + schedule 2474.72 ns 68.57 ns 36.98 ns 1.85
current_thread scheduler create worker + schedule + recursive schedule 3024.46 ns 404.87 ns 201.76 ns 2.01

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 4376.54 ns 7.20 ns 4.01 ns 1.80
immediate_just+scan(10, std::plus)+subscribe 4758.50 ns 0.74 ns 0.45 ns 1.66
immediate_just+flat_map(immediate_just(v*2))+subscribe 13551.72 ns 1037.39 ns 375.16 ns 2.77
immediate_just+buffer(2)+subscribe 4850.72 ns 187.06 ns 64.83 ns 2.89
immediate_just+window(2)+subscribe + subscsribe inner 15166.53 ns 5793.25 ns 2234.46 ns 2.59

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 4315.08 ns - - 0.00
immediate_just+take_while(true)+subscribe 4416.72 ns 0.52 ns 0.22 ns 2.33

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 7501.29 ns 7.64 ns 4.90 ns 1.56

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 11290.11 ns 931.10 ns 416.37 ns 2.24
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 16779.10 ns 666.33 ns 422.39 ns 1.58
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 952.18 ns 438.25 ns 2.17
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 16698.56 ns 4011.82 ns 1818.07 ns 2.21
immediate_just(1) + zip(immediate_just(2)) + subscribe 10740.41 ns 1256.38 ns 803.44 ns 1.56

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 131.27 ns 75.19 ns 47.81 ns 1.57
subscribe 100 observers to publish_subject 738820.50 ns 65851.47 ns 39637.89 ns 1.66
100 on_next to 100 observers to publish_subject 119564.22 ns 43627.39 ns 18244.95 ns 2.39

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 5755.04 ns 127.33 ns 63.35 ns 2.01
basic sample with immediate scheduler 5842.75 ns 28.02 ns 17.50 ns 1.60

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 4798.03 ns 0.35 ns 0.22 ns 1.57

Error Handling Operators

name rxcpp rpp prev rpp ratio
create(on_next(1), on_error())+on_error_resume_next(immediate_just(2)))+subscribe 9955.83 ns 6237.94 ns 3969.55 ns 1.57

ci-ubuntu-clang

General

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

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 572.86 ns 0.31 ns 0.31 ns 1.00
from array of 1 - create + subscribe + current_thread 790.19 ns 4.02 ns 4.32 ns 0.93
concat_as_source of just(1 immediate) create + subscribe 2338.33 ns 135.56 ns 135.97 ns 1.00
defer from array of 1 - defer + create + subscribe + immediate 776.17 ns 0.31 ns 0.31 ns 1.00
interval - interval + take(3) + subscribe + immediate 2216.00 ns 58.31 ns 58.26 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3177.63 ns 31.09 ns 31.06 ns 1.00
from array of 1 - create + as_blocking + subscribe + new_thread 29978.09 ns 27766.82 ns 30439.15 ns 0.91
from array of 1000 - create + as_blocking + subscribe + new_thread 35796.55 ns 36165.06 ns 41374.70 ns 0.87
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 3725.72 ns 158.28 ns 159.05 ns 1.00

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1134.44 ns 0.31 ns 0.31 ns 1.00
immediate_just+filter(true)+subscribe 850.78 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 1078.78 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 862.88 ns 0.62 ns 0.62 ns 1.00
immediate_just(1,2)+first()+subscribe 1380.48 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2)+last()+subscribe 991.93 ns 0.31 ns 0.31 ns 1.00
immediate_just+take_last(1)+subscribe 1191.96 ns 0.31 ns 0.31 ns 1.00
immediate_just(1,2,3)+element_at(1)+subscribe 860.37 ns 0.31 ns - 0.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 278.69 ns 0.88 ns 0.88 ns 1.00
current_thread scheduler create worker + schedule 387.02 ns 4.02 ns 4.63 ns 0.87
current_thread scheduler create worker + schedule + recursive schedule 850.04 ns 57.71 ns 55.55 ns 1.04

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 851.46 ns 0.31 ns 0.31 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 952.38 ns 0.31 ns 0.31 ns 1.00
immediate_just+flat_map(immediate_just(v*2))+subscribe 2238.66 ns 138.32 ns 137.36 ns 1.01
immediate_just+buffer(2)+subscribe 1510.89 ns 13.89 ns 13.98 ns 0.99
immediate_just+window(2)+subscribe + subscsribe inner 2454.94 ns 926.21 ns 938.64 ns 0.99

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 825.78 ns - - 0.00
immediate_just+take_while(true)+subscribe 837.74 ns 0.31 ns 0.31 ns 0.99

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 1972.09 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 3282.42 ns 161.55 ns 160.73 ns 1.01
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 3716.92 ns 147.63 ns 168.35 ns 0.88
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 144.94 ns 141.45 ns 1.02
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 3475.75 ns 865.55 ns 844.80 ns 1.02
immediate_just(1) + zip(immediate_just(2)) + subscribe 2154.14 ns 199.70 ns 202.44 ns 0.99

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 52.21 ns 17.82 ns 17.86 ns 1.00
subscribe 100 observers to publish_subject 213898.20 ns 16000.21 ns 16043.39 ns 1.00
100 on_next to 100 observers to publish_subject 38527.30 ns 18019.25 ns 20714.46 ns 0.87

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1304.53 ns 11.12 ns 12.03 ns 0.92
basic sample with immediate scheduler 1287.05 ns 5.86 ns 5.24 ns 1.12

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 980.33 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 2185.17 ns 1223.03 ns 1212.46 ns 1.01

ci-windows

General

name rxcpp rpp prev rpp ratio
Subscribe empty callbacks to empty observable 568.24 ns 4.02 ns 4.01 ns 1.00
Subscribe empty callbacks to empty observable via pipe operator 584.41 ns 4.01 ns 4.01 ns 1.00

Sources

name rxcpp rpp prev rpp ratio
from array of 1 - create + subscribe + immediate 1169.14 ns 5.55 ns 17.57 ns 0.32
from array of 1 - create + subscribe + current_thread 1430.10 ns 15.75 ns 15.12 ns 1.04
concat_as_source of just(1 immediate) create + subscribe 3762.32 ns 171.75 ns 182.48 ns 0.94
defer from array of 1 - defer + create + subscribe + immediate 1190.93 ns 5.24 ns 16.34 ns 0.32
interval - interval + take(3) + subscribe + immediate 3064.22 ns 133.54 ns 133.44 ns 1.00
interval - interval + take(3) + subscribe + current_thread 3451.45 ns 53.60 ns 52.75 ns 1.02
from array of 1 - create + as_blocking + subscribe + new_thread 119610.00 ns 116590.00 ns 117688.89 ns 0.99
from array of 1000 - create + as_blocking + subscribe + new_thread 129144.44 ns 131644.44 ns 134487.50 ns 0.98
concat_as_source of just(1 immediate) and just(1,2 immediate)create + subscribe 5698.09 ns 209.13 ns 203.72 ns 1.03

Filtering Operators

name rxcpp rpp prev rpp ratio
immediate_just+take(1)+subscribe 1826.26 ns 12.86 ns 12.87 ns 1.00
immediate_just+filter(true)+subscribe 1310.57 ns 11.60 ns 11.64 ns 1.00
immediate_just(1,2)+skip(1)+subscribe 1721.70 ns 13.14 ns 13.09 ns 1.00
immediate_just(1,1,2)+distinct_until_changed()+subscribe 1380.51 ns 15.77 ns 15.83 ns 1.00
immediate_just(1,2)+first()+subscribe 2379.13 ns 12.65 ns 12.64 ns 1.00
immediate_just(1,2)+last()+subscribe 1796.23 ns 14.08 ns 14.11 ns 1.00
immediate_just+take_last(1)+subscribe 2012.07 ns 60.51 ns 60.00 ns 1.01
immediate_just(1,2,3)+element_at(1)+subscribe 1346.01 ns 13.63 ns - 0.00

Schedulers

name rxcpp rpp prev rpp ratio
immediate scheduler create worker + schedule 478.84 ns 6.48 ns 6.17 ns 1.05
current_thread scheduler create worker + schedule 648.72 ns 13.57 ns 14.03 ns 0.97
current_thread scheduler create worker + schedule + recursive schedule 1360.26 ns 107.95 ns 105.29 ns 1.03

Transforming Operators

name rxcpp rpp prev rpp ratio
immediate_just+map(v*2)+subscribe 1309.93 ns 11.26 ns 11.25 ns 1.00
immediate_just+scan(10, std::plus)+subscribe 1423.00 ns 21.29 ns 21.27 ns 1.00
immediate_just+flat_map(immediate_just(v*2))+subscribe 3497.48 ns 201.37 ns 194.11 ns 1.04
immediate_just+buffer(2)+subscribe 2642.89 ns 60.25 ns 59.36 ns 1.02
immediate_just+window(2)+subscribe + subscsribe inner 4046.88 ns 1294.70 ns 1276.02 ns 1.01

Conditional Operators

name rxcpp rpp prev rpp ratio
immediate_just+take_while(false)+subscribe 1323.88 ns 11.47 ns 11.42 ns 1.00
immediate_just+take_while(true)+subscribe 1324.88 ns 11.60 ns 11.65 ns 1.00

Utility Operators

name rxcpp rpp prev rpp ratio
immediate_just(1)+subscribe_on(immediate)+subscribe 3481.29 ns 7.40 ns 19.11 ns 0.39

Combining Operators

name rxcpp rpp prev rpp ratio
immediate_just(immediate_just(1), immediate_just(1)) + merge() + subscribe 5257.27 ns 219.34 ns 213.59 ns 1.03
immediate_just(1) + merge_with(immediate_just(2)) + subscribe 5424.24 ns 218.01 ns 213.04 ns 1.02
immediate_just(1) + with_latest_from(immediate_just(2)) + subscribe - 194.08 ns 196.05 ns 0.99
immediate_just(immediate_just(1),immediate_just(1)) + switch_on_next() + subscribe 5418.96 ns 960.76 ns 937.62 ns 1.02
immediate_just(1) + zip(immediate_just(2)) + subscribe 3571.06 ns 518.28 ns 512.67 ns 1.01

Subjects

name rxcpp rpp prev rpp ratio
publish_subject with 1 observer - on_next 36.70 ns 20.04 ns 20.06 ns 1.00
subscribe 100 observers to publish_subject 262175.00 ns 28350.00 ns 28578.57 ns 0.99
100 on_next to 100 observers to publish_subject 48758.33 ns 35676.67 ns 32625.81 ns 1.09

Scenarios

name rxcpp rpp prev rpp ratio
basic sample 1901.05 ns 56.81 ns 57.75 ns 0.98
basic sample with immediate scheduler 1907.41 ns 36.42 ns 38.25 ns 0.95

Aggregating Operators

name rxcpp rpp prev rpp ratio
immediate_just+reduce(10, std::plus)+subscribe 1461.17 ns 19.95 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 2143.89 ns 343.00 ns 342.01 ns 1.00

Comment thread src/rpp/rpp/operators/element_at.hpp Outdated
Comment thread src/tests/rpp/test_element_at.cpp Outdated
Comment thread src/rpp/rpp/operators/element_at.hpp
Comment thread src/rpp/rpp/operators/element_at.hpp Outdated
Comment thread src/rpp/rpp/operators/element_at.hpp
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1f1051c and e2c46c6.

Files selected for processing (3)
  • src/rpp/rpp/operators/element_at.hpp (1 hunks)
  • src/rpp/rpp/utils/exceptions.hpp (1 hunks)
  • src/tests/rpp/test_element_at.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • src/rpp/rpp/operators/element_at.hpp
  • src/tests/rpp/test_element_at.cpp
Additional comments not posted (1)
src/rpp/rpp/utils/exceptions.hpp (1)

32-35: LGTM! The new out_of_range exception class is well-implemented.

The class is consistent with the existing exception classes and follows best practices for custom exception definitions.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Aug 5, 2024

@victimsnino victimsnino merged commit 1202d8c into victimsnino:v2 Aug 5, 2024
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.

2 participants