fn bench_batch_verify(c: &mut Criterion) {
    let mut group = c.benchmark_group("Batch Verification");
    for &n in [8usize, 16, 24, 32, 40, 48, 56, 64].iter() {
        group.throughput(Throughput::Elements(n as u64));

        let sigs = sigs_with_distinct_keys().take(n).collect::<Vec<_>>();

        group.bench_with_input(
            BenchmarkId::new("Unbatched verification", n),
            &sigs,
            |b, sigs| {
                b.iter(|| {
                    for item in sigs.iter() {
                        match item {
                            Item::SpendAuth { vk_bytes, sig } => {
                                assert!(VerificationKey::try_from(*vk_bytes)
                                    .and_then(|vk| vk.verify(MESSAGE_BYTES, sig))
                                    .is_ok());
                            }
                            Item::Binding { vk_bytes, sig } => {
                                assert!(VerificationKey::try_from(*vk_bytes)
                                    .and_then(|vk| vk.verify(MESSAGE_BYTES, sig))
                                    .is_ok());
                            }
                        }
                    }
                })
            },
        );

        group.bench_with_input(
            BenchmarkId::new("Batched verification", n),
            &sigs,
            |b, sigs| {
                b.iter(|| {
                    let mut batch = batch::Verifier::new();
                    for item in sigs.iter() {
                        match item {
                            Item::SpendAuth { vk_bytes, sig } => {
                                batch.queue((*vk_bytes, *sig, MESSAGE_BYTES));
                            }
                            Item::Binding { vk_bytes, sig } => {
                                batch.queue((*vk_bytes, *sig, MESSAGE_BYTES));
                            }
                        }
                    }
                    assert!(batch.verify(thread_rng()).is_ok())
                })
            },
        );
    }
    group.finish();
}
/// Benchmarks batched vs unbatched RedPallas signature verification.
///
/// Includes heterogeneous groups across [SigType], [SigningKey]s, and messages.
Benchmarks batched vs unbatched RedPallas signature verification.
Includes heterogeneous groups across [SigType], [SigningKey]s, and messages.
Benchmarks batched vs unbatched RedPallas signature verification . Includes heterogeneous groups across [ SigType ] [ SigningKey ] s and messages .
fn bench_batch_verify(c: &mut Criterion) {
    let mut group = c.benchmark_group("Batch Verification");
    for &n in [8usize, 16, 24, 32, 40, 48, 56, 64].iter() {
        group.throughput(Throughput::Elements(n as u64));
        let sigs = sigs_with_distinct_keys().take(n).collect::<Vec<_>>();
        group.bench_with_input(
            BenchmarkId::new("Unbatched verification", n),
            &sigs,
            |b, sigs| {
                b.iter(|| {
                    for item in sigs.iter() {
                        match item {
                            Item::SpendAuth { vk_bytes, sig } => {
                                assert!(VerificationKey::try_from(*vk_bytes)
                                    .and_then(|vk| vk.verify(MESSAGE_BYTES, sig))
                                    .is_ok());
                            }
                            Item::Binding { vk_bytes, sig } => {
                                assert!(VerificationKey::try_from(*vk_bytes)
                                    .and_then(|vk| vk.verify(MESSAGE_BYTES, sig))
                                    .is_ok());
                            }
                        }
                    }
                })
            },
        );
        group.bench_with_input(
            BenchmarkId::new("Batched verification", n),
            &sigs,
            |b, sigs| {
                b.iter(|| {
                    let mut batch = batch::Verifier::new();
                    for item in sigs.iter() {
                        match item {
                            Item::SpendAuth { vk_bytes, sig } => {
                                batch.queue((*vk_bytes, *sig, MESSAGE_BYTES));
                            }
                            Item::Binding { vk_bytes, sig } => {
                                batch.queue((*vk_bytes, *sig, MESSAGE_BYTES));
                            }
                        }
                    }
                    assert!(batch.verify(thread_rng()).is_ok())
                })
            },
        );
    }
    group.finish();
}
fn bench_batch_verify ( c : & mut Criterion ) { let mut group = c . benchmark_group ( " " ) ; for & n in [ 8usize , 16 , 24 , 32 , 40 , 48 , 56 , 64 ] . iter ( ) { group . throughput ( Throughput :: Elements ( n as u64 ) ) ; let sigs = sigs_with_distinct_keys ( ) . take ( n ) . collect :: < Vec < _ > > ( ) ; group . bench_with_input ( BenchmarkId :: new ( " " , n ) , & sigs , | b , sigs | { b . iter ( | | { for item in sigs . iter ( ) { match item { Item :: SpendAuth { vk_bytes , sig } => { assert ! ( VerificationKey try_from ( vk_bytes ) and_then ( vk vk verify ( MESSAGE_BYTES sig ) ) is_ok ( ) ) ; } Item :: Binding { vk_bytes , sig } => { assert ! ( VerificationKey try_from ( vk_bytes ) and_then ( vk vk verify ( MESSAGE_BYTES sig ) ) is_ok ( ) ) ; } } } } ) } , ) ; group . bench_with_input ( BenchmarkId :: new ( " " , n ) , & sigs , | b , sigs | { b . iter ( | | { let mut batch = batch :: Verifier :: new ( ) ; for item in sigs . iter ( ) { match item { Item :: SpendAuth { vk_bytes , sig } => { batch . queue ( ( * vk_bytes , * sig , MESSAGE_BYTES ) ) ; } Item :: Binding { vk_bytes , sig } => { batch . queue ( ( * vk_bytes , * sig , MESSAGE_BYTES ) ) ; } } } assert ! ( batch verify ( thread_rng ( ) ) is_ok ( ) ) } ) } , ) ; } group . finish ( ) ; }
Benchmarks batched vs unbatched RedPallas signature verification.
Benchmarks batched vs unbatched RedPallas signature verification .
c
&mut Criterion