diff --git a/crates/subspace-core-primitives/benches/kzg.rs b/crates/subspace-core-primitives/benches/kzg.rs index 0235da73c9..8e504a0bc9 100644 --- a/crates/subspace-core-primitives/benches/kzg.rs +++ b/crates/subspace-core-primitives/benches/kzg.rs @@ -16,41 +16,48 @@ fn criterion_benchmark(c: &mut Criterion) { }) }); - c.bench_function("commit", |b| { + { let polynomial = kzg.poly(&values).unwrap(); - b.iter(|| { - kzg.commit(black_box(&polynomial)).unwrap(); - }) - }); + + c.bench_function("commit", |b| { + b.iter(|| { + kzg.commit(black_box(&polynomial)).unwrap(); + }) + }); + } let num_values = values.len(); - c.bench_function("create-witness", |b| { + { let polynomial = kzg.poly(&values).unwrap(); - b.iter(|| { - kzg.create_witness(black_box(&polynomial), black_box(num_values), black_box(0)) - .unwrap(); - }) - }); + c.bench_function("create-witness", |b| { + b.iter(|| { + kzg.create_witness(black_box(&polynomial), black_box(num_values), black_box(0)) + .unwrap(); + }) + }); + } - c.bench_function("verify", |b| { + { let polynomial = kzg.poly(&values).unwrap(); let commitment = kzg.commit(&polynomial).unwrap(); let index = 0; let witness = kzg.create_witness(&polynomial, num_values, index).unwrap(); let value = values.first().unwrap(); - b.iter(|| { - kzg.verify( - black_box(&commitment), - black_box(num_values), - black_box(index), - black_box(value), - black_box(&witness), - ); - }) - }); + c.bench_function("verify", |b| { + b.iter(|| { + kzg.verify( + black_box(&commitment), + black_box(num_values), + black_box(index), + black_box(value), + black_box(&witness), + ); + }) + }); + } } criterion_group!(benches, criterion_benchmark); diff --git a/crates/subspace-proof-of-time/benches/pot-compare-cpu-cores.rs b/crates/subspace-proof-of-time/benches/pot-compare-cpu-cores.rs index 51946ad4d6..e9ed5859c5 100644 --- a/crates/subspace-proof-of-time/benches/pot-compare-cpu-cores.rs +++ b/crates/subspace-proof-of-time/benches/pot-compare-cpu-cores.rs @@ -12,10 +12,11 @@ fn criterion_benchmark(c: &mut Criterion) { let cpu_cores = core_affinity::get_core_ids().expect("Must be able to get CPU cores"); for cpu_core in cpu_cores { + if !core_affinity::set_for_current(cpu_core) { + panic!("Failed to set CPU affinity"); + } + c.bench_function(&format!("prove/cpu-{}", cpu_core.id), move |b| { - if !core_affinity::set_for_current(cpu_core) { - panic!("Failed to set CPU affinity"); - } b.iter(|| { black_box(prove(black_box(seed), black_box(pot_iterations))).unwrap(); })