Fix blob size in encoder bench
This commit is contained in:
parent
3fef984fe9
commit
ee66796db5
|
@ -1,7 +1,6 @@
|
||||||
use divan::counter::BytesCount;
|
use divan::counter::BytesCount;
|
||||||
use divan::Bencher;
|
use divan::Bencher;
|
||||||
use kzgrs_backend::encoder::{DaEncoder, DaEncoderParams};
|
use kzgrs_backend::encoder::{DaEncoder, DaEncoderParams};
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use std::hint::black_box;
|
use std::hint::black_box;
|
||||||
|
|
||||||
|
@ -9,22 +8,23 @@ fn main() {
|
||||||
divan::main()
|
divan::main()
|
||||||
}
|
}
|
||||||
|
|
||||||
static ENCODER: Lazy<DaEncoder> = Lazy::new(|| {
|
const MB1: usize = 1024 * 1024;
|
||||||
let params = DaEncoderParams::new(4096, true);
|
|
||||||
DaEncoder::new(params)
|
|
||||||
});
|
|
||||||
|
|
||||||
const KB: usize = 1024;
|
|
||||||
|
|
||||||
pub fn rand_data(elements_count: usize) -> Vec<u8> {
|
pub fn rand_data(elements_count: usize) -> Vec<u8> {
|
||||||
let mut buff = vec![0; elements_count * DaEncoderParams::MAX_BLS12_381_ENCODING_CHUNK_SIZE];
|
let mut buff = vec![0; elements_count * DaEncoderParams::MAX_BLS12_381_ENCODING_CHUNK_SIZE];
|
||||||
rand::thread_rng().fill_bytes(&mut buff);
|
rand::thread_rng().fill_bytes(&mut buff);
|
||||||
buff
|
buff
|
||||||
}
|
}
|
||||||
#[divan::bench(args = [32, 64, 128, 256, 512, 1024, 2048], sample_count = 1, sample_size = 1)]
|
#[divan::bench(args = [128, 256, 512, 1024, 2048, 4096], sample_count = 1, sample_size = 1)]
|
||||||
fn encode(bencher: Bencher, size: usize) {
|
fn encode(bencher: Bencher, column_size: usize) {
|
||||||
bencher
|
bencher
|
||||||
.with_inputs(|| rand_data(size * KB / DaEncoderParams::MAX_BLS12_381_ENCODING_CHUNK_SIZE))
|
.with_inputs(|| {
|
||||||
.input_counter(|buff| BytesCount::new(buff.len()))
|
let params = DaEncoderParams::new(column_size, true);
|
||||||
.bench_refs(|buff| black_box(ENCODER.encode(buff)));
|
(
|
||||||
|
DaEncoder::new(params),
|
||||||
|
rand_data(MB1 / DaEncoderParams::MAX_BLS12_381_ENCODING_CHUNK_SIZE),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.input_counter(|(_, buff)| BytesCount::new(buff.len()))
|
||||||
|
.bench_refs(|(encoder, buff)| black_box(encoder.encode(buff)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue