fn handle_ingress(criterion: &mut Criterion) {
    let mut group = criterion.benchmark_group("handle_ingress");
    group.sample_size(10);
    group.measurement_time(Duration::from_secs(10));
    for i in 1..=10 {
        // num messages per second
        let ingress_rate = i * 100;
        // We don't have to run the benchmark for the full TTL interval. Ending in 30
        // simulated seconds is good enough.
        let time_span = Duration::from_secs(30);
        // range of ingress expiry
        let expiry_range = MAX_INGRESS_TTL + time_span;
        let total_messages = ingress_rate * expiry_range.as_secs();
        run_test(
            "get_ingress_payload",
            |time_source: Arc<FastForwardTimeSource>,
             pool_config: ArtifactPoolConfig,
             log: ReplicaLogger,
             history: &SimulatedIngressHistory,
             manager: &mut IngressManager| {
                let name = format!("handle_ingress({})", ingress_rate);
                let messages = prepare(time_source.as_ref(), expiry_range, total_messages as usize);
                let (pool, message_ids) = setup(time_source.as_ref(), pool_config, log, messages);
                group.bench_function(&name, |bench| {
                    bench.iter_custom(|iters| {
                        let mut elapsed = Duration::from_secs(0);
                        for _ in 0..iters {
                            let bench_start = Instant::now();
                            let mut ingress_pool = pool.clone();
                            time_source.reset();
                            // We skip the first MAX_INGRESS_TTL duration in order to save
                            // overall benchmark time. Also by this time, the ingress
                            // history has become fully populated.
                            let start = time_source.get_relative_time() + MAX_INGRESS_TTL;
                            time_source.set_time(start).unwrap();
                            history.set_history(message_ids.clone());
                            // Increment time every 200ms until it is over.
                            loop {
                                on_state_change(&mut ingress_pool, manager);
                                let now = time_source.get_relative_time();
                                if now >= start + time_span {
                                    break;
                                }
                                time_source
                                    .set_time(now + Duration::from_millis(200))
                                    .unwrap();
                            }
                            elapsed += bench_start.elapsed();
                        }
                        elapsed
                    })
                });
            },
        );
    }
    group.finish()
}
/// Speed test for ingress handling.
Speed test for ingress handling.
Speed test for ingress handling .
fn handle_ingress(criterion: &mut Criterion) {
    let mut group = criterion.benchmark_group("handle_ingress");
    group.sample_size(10);
    group.measurement_time(Duration::from_secs(10));
    for i in 1..=10 {
        // num messages per second
        let ingress_rate = i * 100;
        // We don't have to run the benchmark for the full TTL interval. Ending in 30
        // simulated seconds is good enough.
        let time_span = Duration::from_secs(30);
        // range of ingress expiry
        let expiry_range = MAX_INGRESS_TTL + time_span;
        let total_messages = ingress_rate * expiry_range.as_secs();
        run_test(
            "get_ingress_payload",
            |time_source: Arc<FastForwardTimeSource>,
             pool_config: ArtifactPoolConfig,
             log: ReplicaLogger,
             history: &SimulatedIngressHistory,
             manager: &mut IngressManager| {
                let name = format!("handle_ingress({})", ingress_rate);
                let messages = prepare(time_source.as_ref(), expiry_range, total_messages as usize);
                let (pool, message_ids) = setup(time_source.as_ref(), pool_config, log, messages);
                group.bench_function(&name, |bench| {
                    bench.iter_custom(|iters| {
                        let mut elapsed = Duration::from_secs(0);
                        for _ in 0..iters {
                            let bench_start = Instant::now();
                            let mut ingress_pool = pool.clone();
                            time_source.reset();
                            // We skip the first MAX_INGRESS_TTL duration in order to save
                            // overall benchmark time. Also by this time, the ingress
                            // history has become fully populated.
                            let start = time_source.get_relative_time() + MAX_INGRESS_TTL;
                            time_source.set_time(start).unwrap();
                            history.set_history(message_ids.clone());
                            // Increment time every 200ms until it is over.
                            loop {
                                on_state_change(&mut ingress_pool, manager);
                                let now = time_source.get_relative_time();
                                if now >= start + time_span {
                                    break;
                                }
                                time_source
                                    .set_time(now + Duration::from_millis(200))
                                    .unwrap();
                            }
                            elapsed += bench_start.elapsed();
                        }
                        elapsed
                    })
                });
            },
        );
    }
    group.finish()
}
fn handle_ingress ( criterion : & mut Criterion ) { let mut group = criterion . benchmark_group ( " " ) ; group . sample_size ( 10 ) ; group . measurement_time ( Duration :: from_secs ( 10 ) ) ; for i in 1 ..= 10 { // num messages per second let ingress_rate = i * 100 ; // We don't have to run the benchmark for the full TTL interval. Ending in 30 // simulated seconds is good enough. let time_span = Duration :: from_secs ( 30 ) ; // range of ingress expiry let expiry_range = MAX_INGRESS_TTL + time_span ; let total_messages = ingress_rate * expiry_range . as_secs ( ) ; run_test ( " " , | time_source : Arc < FastForwardTimeSource > , pool_config : ArtifactPoolConfig , log : ReplicaLogger , history : & SimulatedIngressHistory , manager : & mut IngressManager | { let name = format ! ( " " ingress_rate ) ; let messages = prepare ( time_source . as_ref ( ) , expiry_range , total_messages as usize ) ; let ( pool , message_ids ) = setup ( time_source . as_ref ( ) , pool_config , log , messages ) ; group . bench_function ( & name , | bench | { bench . iter_custom ( | iters | { let mut elapsed = Duration :: from_secs ( 0 ) ; for _ in 0 .. iters { let bench_start = Instant :: now ( ) ; let mut ingress_pool = pool . clone ( ) ; time_source . reset ( ) ; // We skip the first MAX_INGRESS_TTL duration in order to save // overall benchmark time. Also by this time, the ingress // history has become fully populated. let start = time_source . get_relative_time ( ) + MAX_INGRESS_TTL ; time_source . set_time ( start ) . unwrap ( ) ; history . set_history ( message_ids . clone ( ) ) ; // Increment time every 200ms until it is over. loop { on_state_change ( & mut ingress_pool , manager ) ; let now = time_source . get_relative_time ( ) ; if now >= start + time_span { break ; } time_source . set_time ( now + Duration :: from_millis ( 200 ) ) . unwrap ( ) ; } elapsed += bench_start . elapsed ( ) ; } elapsed } ) } ) ; } , ) ; } group . finish ( ) }
Speed test for ingress handling.
Speed test for ingress handling .
criterion
&mut Criterion
criterion
&mut Criterion