Skip to content

Commit

Permalink
Use BatchSize::LargeInput if input size exceeds 512 bytes
Browse files Browse the repository at this point in the history
Criterion.rs documentation states that "SmallInput indicates that the
input to the benchmark routine [...] is small enough that millions of
values can be safely held in memory." 0.5KB seems like a good cutoff
to use to start using LargeInput, if we take "millions of values" to
mean ~5,000,000.
  • Loading branch information
kennethloeffler committed Nov 2, 2024
1 parent 1bb13cc commit f67f4ca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rbx_binary/benches/suite/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ fn serialize_bench<T: Measurement>(group: &mut BenchmarkGroup<T>, buffer: &[u8])

rbx_binary::to_writer(&mut buffer, &tree, &[root_ref]).unwrap();
let buffer_len = buffer.len();
let batch_size = if buffer_len > 512 {
BatchSize::LargeInput
} else {
BatchSize::SmallInput
};

group
.throughput(Throughput::Bytes(buffer_len as u64))
Expand All @@ -21,7 +26,7 @@ fn serialize_bench<T: Measurement>(group: &mut BenchmarkGroup<T>, buffer: &[u8])
|mut buffer: Vec<u8>| {
rbx_binary::to_writer(&mut buffer, &tree, &[root_ref]).unwrap();
},
BatchSize::SmallInput,
batch_size,
)
});
}
Expand Down

0 comments on commit f67f4ca

Please sign in to comment.