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

[#483] Add --send-copy flag to pub/sub benchmark #484

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions benchmarks/publish-subscribe/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

use std::mem::MaybeUninit;

use clap::Parser;
use iceoryx2::prelude::*;
use iceoryx2_bb_log::set_log_level;
Expand Down Expand Up @@ -60,11 +62,17 @@ fn perform_benchmark<T: Service>(args: &Args) -> Result<(), Box<dyn std::error::

barrier.wait();

let mut sample = unsafe {
sender_a2b
.loan_slice_uninit(args.payload_size)
.unwrap()
.assume_init()
let mut sample = if args.send_copy {
let mut sample = sender_a2b.loan_slice_uninit(args.payload_size).unwrap();
sample.payload_mut().fill(MaybeUninit::new(0));
unsafe { sample.assume_init() }
} else {
unsafe {
sender_a2b
.loan_slice_uninit(args.payload_size)
.unwrap()
.assume_init()
}
};

for _ in 0..args.iterations {
Expand Down Expand Up @@ -93,12 +101,19 @@ fn perform_benchmark<T: Service>(args: &Args) -> Result<(), Box<dyn std::error::
barrier.wait();

for _ in 0..args.iterations {
let sample = unsafe {
sender_b2a
.loan_slice_uninit(args.payload_size)
.unwrap()
.assume_init()
let sample = if args.send_copy {
let mut sample = sender_b2a.loan_slice_uninit(args.payload_size).unwrap();
sample.payload_mut().fill(MaybeUninit::new(0));
unsafe { sample.assume_init() }
} else {
unsafe {
sender_b2a
.loan_slice_uninit(args.payload_size)
.unwrap()
.assume_init()
}
};

while receiver_a2b.receive().unwrap().is_none() {}

sample.send().unwrap();
Expand Down Expand Up @@ -152,6 +167,8 @@ struct Args {
/// The size in bytes of the payload that shall be used
#[clap(short, long, default_value_t = 8192)]
payload_size: usize,
#[clap(long)]
send_copy: bool,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
5 changes: 3 additions & 2 deletions doc/release-notes/iceoryx2-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Add Event-Multiplexer `WaitSet` [#390](https://github.com/eclipse-iceoryx/iceoryx2/issues/390)
* Add `PeriodicTimer` into POSIX building blocks [#425](https://github.com/eclipse-iceoryx/iceoryx2/issues/425)
* Developer permissions for resources [#460](https://github.com/eclipse-iceoryx/iceoryx2/issues/460)
* Add `--send-copy` flag to Benchmark to consider mem operations [#483](https://github.com/eclipse-iceoryx/iceoryx2/issues/483)

### Bugfixes

Expand Down Expand Up @@ -58,7 +59,7 @@

### API Breaking Changes

1. Renamed `NodeEvent` into `WaitEvent`
1. Removed `NodeEvent`. `Node::wait` returns now `Result<(), NodeWaitFailure>`

```rust
// old
Expand All @@ -67,7 +68,7 @@
}

// new
while node.wait(CYCLE_TIME) != WaitEvent::TerminationRequest {
while node.wait(CYCLE_TIME).is_ok() {
// ...
}
```
Loading