Macro queuecheck::queuecheck_bench_throughput[][src]

macro_rules! queuecheck_bench_throughput {
    ($pairs:expr, $producers:expr, $consumers:expr, $produce:expr, $consume:expr) => { ... };
}

Benchmarks the throughput of the supplied queue.

Example

The below benchmarks the throughput of the unbounded MPMC queue from the standard library by producing 100,000 items using two producer threads which are then consumed by one consumer thread.

use std::sync::mpsc::{self, Receiver, Sender};

let (producer, consumer) = mpsc::channel();

let ops = queuecheck_bench_throughput!(
    // warmup and measurement enqueue/dequeue operation pairs
    (1_000, 100_000),
    // producer threads
    vec![producer.clone(), producer],
    // consumer threads
    vec![consumer],
    // produce operation
    |p: &Sender<i32>, i: i32| p.send(i).unwrap(),
    // consume operation
    |c: &Receiver<i32>| c.try_recv().ok()
);

println!("{:.3} operation/second", ops);