#![allow(
missing_docs,
unused_qualifications,
unreachable_pub,
clippy::must_use_candidate,
clippy::needless_pass_by_value
)]
mod common;
use std::hint::black_box;
use common::{Latch, MESSAGES, Order, Pending};
use gungraun::{library_benchmark, library_benchmark_group, main};
use ruststream::memory::prelude::*;
use serde::Serialize;
#[derive(Debug, Serialize, Outgoing)]
#[outgoing(name = "confirmations")]
struct Confirmation {
id: u64,
}
#[subscriber("orders", reply)]
async fn confirm(order: &Order, ctx: &mut Context<'_, (), Latch>) -> Confirmation {
ctx.state().arrived();
Confirmation {
id: black_box(order.id),
}
}
fn app(messages: usize) -> Pending {
common::pending(messages, 0, |b| {
b.include(confirm);
})
}
#[library_benchmark(config = common::config(2, 28))]
#[bench::first(app(1))]
#[bench::base(app(MESSAGES))]
#[bench::twice(app(2 * MESSAGES))]
fn service(app: Pending) {
common::start_and_drain(app);
}
library_benchmark_group!(name = reply; benchmarks = service);
main!(library_benchmark_groups = reply);