Skip to content

Commit

Permalink
long variable names
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <[email protected]>
  • Loading branch information
sagudev committed Aug 19, 2024
1 parent 743d121 commit 9f7a155
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
18 changes: 9 additions & 9 deletions benches/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use ipc_channel::ipc;
/// as the benchmark framework doesn't know about the inner iterations...
const ITERATIONS: usize = 1;

fn transfer_empty(c: &mut Criterion) {
c.bench_function("transfer_empty", |b| {
fn transfer_empty(criterion: &mut Criterion) {
criterion.bench_function("transfer_empty", |bencher| {
let (tx, rx) = ipc::channel().unwrap();
b.iter(|| {
bencher.iter(|| {
for _ in 0..ITERATIONS {
tx.send(()).unwrap();
rx.recv().unwrap()
Expand All @@ -24,15 +24,15 @@ fn transfer_empty(c: &mut Criterion) {
});
}

fn transfer_senders<const COUNT: usize>(c: &mut Criterion) {
c.bench_function(&format!("transfer_senders_{COUNT:02}"), |b| {
fn transfer_senders<const COUNT: usize>(criterion: &mut Criterion) {
criterion.bench_function(&format!("transfer_senders_{COUNT:02}"), |bencher| {
let (main_tx, main_rx) = ipc::channel().unwrap();
let transfer_txs: Vec<_> = (0..COUNT)
.map(|_| ipc::channel::<()>().unwrap())
.map(|(tx, _)| tx)
.collect();
let mut transfer_txs = Some(transfer_txs);
b.iter(|| {
bencher.iter(|| {
for _ in 0..ITERATIONS {
main_tx.send(transfer_txs.take().unwrap()).unwrap();
transfer_txs = Some(main_rx.recv().unwrap());
Expand All @@ -41,15 +41,15 @@ fn transfer_senders<const COUNT: usize>(c: &mut Criterion) {
});
}

fn transfer_receivers<const COUNT: usize>(c: &mut Criterion) {
c.bench_function(&format!("transfer_receivers_{COUNT:02}"), |b| {
fn transfer_receivers<const COUNT: usize>(criterion: &mut Criterion) {
criterion.bench_function(&format!("transfer_receivers_{COUNT:02}"), |bencher| {
let (main_tx, main_rx) = ipc::channel().unwrap();
let transfer_rxs: Vec<_> = (0..COUNT)
.map(|_| ipc::channel::<()>().unwrap())
.map(|(_, rx)| rx)
.collect();
let mut transfer_rxs = Some(transfer_rxs);
b.iter(|| {
bencher.iter(|| {
for _ in 0..ITERATIONS {
main_tx.send(transfer_rxs.take().unwrap()).unwrap();
transfer_rxs = Some(main_rx.recv().unwrap());
Expand Down
18 changes: 9 additions & 9 deletions benches/ipc_receiver_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ use ipc_channel::ipc::{self, IpcReceiverSet};

/// Benchmark selecting over a set of `n` receivers,
/// with `to_send` of them actually having pending data.
fn bench_send_on_m_of_n<const TO_SEND: usize, const N: usize>(c: &mut Criterion) {
c.bench_function(&format!("bench_send_on_{TO_SEND}_of_{N}"), |b| {
fn bench_send_on_m_of_n<const TO_SEND: usize, const N: usize>(criterion: &mut Criterion) {
criterion.bench_function(&format!("bench_send_on_{TO_SEND}_of_{N}"), |bencher| {
let mut senders = Vec::with_capacity(N);
let mut rx_set = IpcReceiverSet::new().unwrap();
for _ in 0..N {
let (tx, rx) = ipc::channel().unwrap();
rx_set.add(rx).unwrap();
senders.push(tx);
}
b.iter(|| {
bencher.iter(|| {
for _ in 0..ITERATIONS {
for tx in senders.iter().take(TO_SEND) {
tx.send(()).unwrap();
Expand All @@ -47,9 +47,9 @@ fn create_set_of_n<const N: usize>() -> IpcReceiverSet {
rx_set
}

fn create_and_destroy_set_of_n<const N: usize>(c: &mut Criterion) {
c.bench_function(&format!("create_and_destroy_set_of_{N}"), |b| {
b.iter(|| {
fn create_and_destroy_set_of_n<const N: usize>(criterion: &mut Criterion) {
criterion.bench_function(&format!("create_and_destroy_set_of_{N}"), |bencher| {
bencher.iter(|| {
for _ in 0..ITERATIONS {
create_set_of_n::<N>();
}
Expand All @@ -60,9 +60,9 @@ fn create_and_destroy_set_of_n<const N: usize>(c: &mut Criterion) {
// Benchmark performance of removing closed receivers from set.
// This also includes the time for adding receivers,
// as there is no way to measure the removing in isolation.
fn add_and_remove_n_closed_receivers<const N: usize>(c: &mut Criterion) {
c.bench_function(&format!("add_and_remove_{N}_closed_receivers"), |b| {
b.iter(|| {
fn add_and_remove_n_closed_receivers<const N: usize>(criterion: &mut Criterion) {
criterion.bench_function(&format!("add_and_remove_{N}_closed_receivers"), |bencher| {
bencher.iter(|| {
for _ in 0..ITERATIONS {
// We could keep adding/removing senders to the same set,
// instead of creating a new one in each iteration.
Expand Down
14 changes: 7 additions & 7 deletions benches/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ use std::sync::{mpsc, Mutex};
/// as the benchmark framework doesn't know about the inner iterations...
const ITERATIONS: usize = 1;

fn create_channel(c: &mut Criterion) {
c.bench_function("create_channel", |b| {
b.iter(|| {
fn create_channel(criterion: &mut Criterion) {
criterion.bench_function("create_channel", |bencher| {
bencher.iter(|| {
for _ in 0..ITERATIONS {
platform::channel().unwrap();
}
});
});
}

fn transfer_data<const SIZE: usize>(c: &mut Criterion) {
c.bench_function(&format!("transfer_data_{SIZE}"), |b| {
fn transfer_data<const SIZE: usize>(criterion: &mut Criterion) {
criterion.bench_function(&format!("transfer_data_{SIZE}"), |bencher| {
let data: Vec<u8> = (0..SIZE).map(|i| (i % 251) as u8).collect();
let (tx, rx) = platform::channel().unwrap();

let (wait_tx, wait_rx) = mpsc::channel();
let wait_rx = Mutex::new(wait_rx);

if SIZE > platform::OsIpcSender::get_max_fragment_size() {
b.iter(|| {
bencher.iter(|| {
crossbeam_utils::thread::scope(|scope| {
let tx = tx.clone();
scope.spawn(|_| {
Expand Down Expand Up @@ -63,7 +63,7 @@ fn transfer_data<const SIZE: usize>(c: &mut Criterion) {
})
});
} else {
b.iter(|| {
bencher.iter(|| {
for _ in 0..ITERATIONS {
tx.send(&data, vec![], vec![]).unwrap();
rx.recv().unwrap();
Expand Down

0 comments on commit 9f7a155

Please sign in to comment.