mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
bench: Add benchmark for prevector usage in std::vector
This commit is contained in:
parent
e352f5ab6b
commit
d380d2877e
1 changed files with 26 additions and 0 deletions
|
@ -80,6 +80,30 @@ static void PrevectorDeserialize(benchmark::Bench& bench)
|
|||
});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void PrevectorFillVectorDirect(benchmark::Bench& bench)
|
||||
{
|
||||
bench.run([&] {
|
||||
std::vector<prevector<28, T>> vec;
|
||||
for (size_t i = 0; i < 260; ++i) {
|
||||
vec.emplace_back();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
static void PrevectorFillVectorIndirect(benchmark::Bench& bench)
|
||||
{
|
||||
bench.run([&] {
|
||||
std::vector<prevector<28, T>> vec;
|
||||
for (size_t i = 0; i < 260; ++i) {
|
||||
// force allocation
|
||||
vec.emplace_back(29, T{});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#define PREVECTOR_TEST(name) \
|
||||
static void Prevector##name##Nontrivial(benchmark::Bench& bench) \
|
||||
{ \
|
||||
|
@ -96,3 +120,5 @@ PREVECTOR_TEST(Clear)
|
|||
PREVECTOR_TEST(Destructor)
|
||||
PREVECTOR_TEST(Resize)
|
||||
PREVECTOR_TEST(Deserialize)
|
||||
PREVECTOR_TEST(FillVectorDirect)
|
||||
PREVECTOR_TEST(FillVectorIndirect)
|
||||
|
|
Loading…
Reference in a new issue