fix: Use size_of T instead of hardcoded 8

pull/24376/head
Carol (Nichols || Goulding) 2020-02-14 12:47:13 -05:00
parent 6463601676
commit 78b008a062
1 changed files with 4 additions and 1 deletions

View File

@ -2,6 +2,7 @@ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Through
use rand::{distributions::Uniform, Rng}; use rand::{distributions::Uniform, Rng};
use std::convert::TryFrom; use std::convert::TryFrom;
use std::mem;
mod fixtures; mod fixtures;
@ -37,7 +38,9 @@ fn benchmark_encode<T>(
) { ) {
let mut group = c.benchmark_group(benchmark_group_name); let mut group = c.benchmark_group(benchmark_group_name);
for &batch_size in batch_sizes { for &batch_size in batch_sizes {
group.throughput(Throughput::Bytes(u64::try_from(batch_size).unwrap() * 8)); group.throughput(Throughput::Bytes(
u64::try_from(batch_size * mem::size_of::<T>()).unwrap(),
));
group.bench_with_input( group.bench_with_input(
BenchmarkId::from_parameter(batch_size), BenchmarkId::from_parameter(batch_size),
&batch_size, &batch_size,