refactor: use SpanReader in PrevectorDeserialize

`PrevectorDeserialize` only needs a reusable read-only view over fixed serialized bytes.
Keeping a mutable `DataStream` around just to call `Rewind()` is unnecessary.

Rebuild a fresh `SpanReader` for each benchmark run and remove `DataStream::Rewind()`, whose remaining use was this benchmark-only reset path.
The benchmark can now serialize exactly the 1000 entries it deserializes, so drop the stale extra element that used to avoid full consumption.

Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
This commit is contained in:
Lőrinc
2026-04-07 23:33:49 +03:00
parent b8eb6c2081
commit 2529f25555
2 changed files with 5 additions and 20 deletions

View File

@@ -66,22 +66,22 @@ static void PrevectorResize(benchmark::Bench& bench)
template <typename T>
static void PrevectorDeserialize(benchmark::Bench& bench)
{
DataStream s0{};
DataStream data{};
prevector<CScriptBase::STATIC_SIZE, T> t0;
t0.resize(CScriptBase::STATIC_SIZE);
for (auto x = 0; x < 900; ++x) {
s0 << t0;
data << t0;
}
t0.resize(100);
for (auto x = 0; x < 101; ++x) {
s0 << t0;
for (auto x = 0; x < 100; ++x) {
data << t0;
}
bench.batch(1000).run([&] {
SpanReader s0{data};
prevector<CScriptBase::STATIC_SIZE, T> t1;
for (auto x = 0; x < 1000; ++x) {
s0 >> t1;
}
s0.Rewind();
});
}