From f67f4cabf5bd730cbad53c0c185361178870b34b Mon Sep 17 00:00:00 2001 From: kennethloeffler Date: Sat, 2 Nov 2024 12:39:57 +0000 Subject: [PATCH] Use BatchSize::LargeInput if input size exceeds 512 bytes 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. --- rbx_binary/benches/suite/util.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rbx_binary/benches/suite/util.rs b/rbx_binary/benches/suite/util.rs index 8e835132..687151ef 100644 --- a/rbx_binary/benches/suite/util.rs +++ b/rbx_binary/benches/suite/util.rs @@ -12,6 +12,11 @@ fn serialize_bench(group: &mut BenchmarkGroup, 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)) @@ -21,7 +26,7 @@ fn serialize_bench(group: &mut BenchmarkGroup, buffer: &[u8]) |mut buffer: Vec| { rbx_binary::to_writer(&mut buffer, &tree, &[root_ref]).unwrap(); }, - BatchSize::SmallInput, + batch_size, ) }); }