queuecheck 0.1.1

A thread-safe queue testing and benchmarking library.
Documentation
  • Coverage
  • 100%
    11 out of 11 items documented3 out of 8 items with examples
  • Size
  • Source code size: 28.70 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 677.50 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • KyleMayes/queuecheck
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • KyleMayes

queuecheck

crates.io docs.rs Travis CI

A thread-safe queue testing and benchmarking library.

Supported on the stable, beta, and nightly Rust channels.

Released under the Apache License 2.0.

Examples

Testing

The below tests 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();

queuecheck_test!(
    // enqueue/dequeue operation pairs
    100_000,
    // producer threads
    vec![producer.clone(), producer],
    // consumer threads
    vec![consumer],
    // produce operation
    |p: &Sender<String>, i: String| p.send(i).unwrap(),
    // consume operation
    |c: &Receiver<String>| c.try_recv().ok()
);

Benchmarking

Latency

The below benchmarks the latency 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 latency = queuecheck_bench_latency!(
    // 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()
);

latency.report("mpmc", &[50.0, 70.0, 90.0, 95.0, 99.09]);

Throughput

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);