Added const sizes to encoder bench (#671)

This commit is contained in:
Daniel Sanchez 2024-07-03 12:55:05 +02:00 committed by GitHub
parent c9c94c4e55
commit 77e65c96e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -8,21 +8,21 @@ fn main() {
divan::main()
}
const MB1: usize = 1024 * 1024;
const MB: usize = 1024;
pub fn rand_data(elements_count: usize) -> Vec<u8> {
let mut buff = vec![0; elements_count * DaEncoderParams::MAX_BLS12_381_ENCODING_CHUNK_SIZE];
rand::thread_rng().fill_bytes(&mut buff);
buff
}
#[divan::bench(args = [128, 256, 512, 1024, 2048, 4096], sample_count = 1, sample_size = 1)]
fn encode(bencher: Bencher, column_size: usize) {
#[divan::bench(consts = [32, 64, 128, 256, 512, 1024], args = [128, 256, 512, 1024, 2048, 4096], sample_count = 1, sample_size = 1)]
fn encode<const SIZE: usize>(bencher: Bencher, column_size: usize) {
bencher
.with_inputs(|| {
let params = DaEncoderParams::new(column_size, true);
(
DaEncoder::new(params),
rand_data(MB1 / DaEncoderParams::MAX_BLS12_381_ENCODING_CHUNK_SIZE),
rand_data(SIZE * MB / DaEncoderParams::MAX_BLS12_381_ENCODING_CHUNK_SIZE),
)
})
.input_counter(|(_, buff)| BytesCount::new(buff.len()))