Skip to content

Commit 764cdf1

Browse files
committed
Extend micro-benchmark for count_min_sketch serialization
1 parent 4e66c11 commit 764cdf1

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

benchmarks/benchmark_count_min_sketch_serialization.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,29 @@ void BM_CountMinSerializeOStream(benchmark::State& state)
133133
state.SetBytesProcessed(state.iterations() * static_cast<int64_t>(serialized_size));
134134
}
135135

136+
void BM_CountMinSerializeToSink(benchmark::State& state)
137+
{
138+
const auto sketch = makeSketch(static_cast<uint32_t>(state.range(0)));
139+
const auto serialized_size = sketch.get_serialized_size_bytes();
140+
std::vector<uint8_t> bytes(serialized_size);
141+
142+
for (auto _ : state) {
143+
uint8_t* ptr = bytes.data();
144+
const auto bytes_written = sketch.serialize_to([&ptr](const void* data, size_t size) {
145+
std::memcpy(ptr, data, size);
146+
ptr += size;
147+
});
148+
benchmark::DoNotOptimize(ptr);
149+
benchmark::DoNotOptimize(bytes_written);
150+
benchmark::ClobberMemory();
151+
}
152+
153+
state.SetBytesProcessed(state.iterations() * static_cast<int64_t>(serialized_size));
154+
}
155+
136156
}
137157

138158
BENCHMARK(BM_CountMinGetSerializedSizeBytes)->RangeMultiplier(8)->Range(1024, 65536);
139159
BENCHMARK(BM_CountMinSerializeVector)->RangeMultiplier(8)->Range(1024, 65536);
140160
BENCHMARK(BM_CountMinSerializeOStream)->RangeMultiplier(8)->Range(1024, 65536);
161+
BENCHMARK(BM_CountMinSerializeToSink)->RangeMultiplier(8)->Range(1024, 65536);

0 commit comments

Comments
 (0)