mirror of
https://github.com/status-im/c-kzg-4844.git
synced 2025-01-09 09:52:03 +00:00
Fix rust benches to work with the new compute API (#194)
This commit is contained in:
parent
fa851f1b2c
commit
ef82131be6
@ -23,20 +23,6 @@ fn generate_random_blob(rng: &mut ThreadRng) -> Blob {
|
|||||||
arr.into()
|
arr.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_random_commitment(rng: &mut ThreadRng, s: &KZGSettings) -> Bytes48 {
|
|
||||||
let blob = generate_random_blob(rng);
|
|
||||||
KZGCommitment::blob_to_kzg_commitment(blob, s)
|
|
||||||
.unwrap()
|
|
||||||
.to_bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn generate_random_proof(rng: &mut ThreadRng, s: &KZGSettings) -> Bytes48 {
|
|
||||||
let blob = generate_random_blob(rng);
|
|
||||||
KZGProof::compute_blob_kzg_proof(blob, s)
|
|
||||||
.unwrap()
|
|
||||||
.to_bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||||
let max_count: usize = 64;
|
let max_count: usize = 64;
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
@ -47,11 +33,22 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
let blobs: Vec<Blob> = (0..max_count)
|
let blobs: Vec<Blob> = (0..max_count)
|
||||||
.map(|_| generate_random_blob(&mut rng))
|
.map(|_| generate_random_blob(&mut rng))
|
||||||
.collect();
|
.collect();
|
||||||
let commitments: Vec<Bytes48> = (0..max_count)
|
let commitments: Vec<Bytes48> = blobs
|
||||||
.map(|_| generate_random_commitment(&mut rng, &kzg_settings))
|
.iter()
|
||||||
|
.map(|blob| {
|
||||||
|
KZGCommitment::blob_to_kzg_commitment(*blob, &kzg_settings)
|
||||||
|
.unwrap()
|
||||||
|
.to_bytes()
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let proofs: Vec<Bytes48> = (0..max_count)
|
let proofs: Vec<Bytes48> = blobs
|
||||||
.map(|_| generate_random_proof(&mut rng, &kzg_settings))
|
.iter()
|
||||||
|
.zip(commitments.iter())
|
||||||
|
.map(|(blob, commitment)| {
|
||||||
|
KZGProof::compute_blob_kzg_proof(*blob, *commitment, &kzg_settings)
|
||||||
|
.unwrap()
|
||||||
|
.to_bytes()
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let fields: Vec<Bytes32> = (0..max_count)
|
let fields: Vec<Bytes32> = (0..max_count)
|
||||||
.map(|_| generate_random_field_element(&mut rng))
|
.map(|_| generate_random_field_element(&mut rng))
|
||||||
@ -72,7 +69,13 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
c.bench_function("compute_blob_kzg_proof", |b| {
|
c.bench_function("compute_blob_kzg_proof", |b| {
|
||||||
b.iter(|| KZGProof::compute_blob_kzg_proof(*blobs.first().unwrap(), &kzg_settings))
|
b.iter(|| {
|
||||||
|
KZGProof::compute_blob_kzg_proof(
|
||||||
|
*blobs.first().unwrap(),
|
||||||
|
*commitments.first().unwrap(),
|
||||||
|
&kzg_settings,
|
||||||
|
)
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
c.bench_function("verify_blob_kzg_proof", |b| {
|
c.bench_function("verify_blob_kzg_proof", |b| {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user