mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 17:54:19 +02:00
Merge #9505: Prevector Quick Destruct
45a5aafOnly call clear on prevector if it isn't trivially destructible and don't loop in clear (Jeremy Rubin)aaa02e7Add prevector destructor benchmark (Jeremy Rubin) Tree-SHA512: 52bc8163b65b71310252f2d578349d0ddc364a6c23795c5e06e101f5449f04c96cbdca41c0cffb1974b984b8e33006471137d92b8dd4a81a98e922610a94132a
This commit is contained in:
36
src/bench/prevector_destructor.cpp
Normal file
36
src/bench/prevector_destructor.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2015-2017 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "bench.h"
|
||||
#include "prevector.h"
|
||||
|
||||
static void PrevectorDestructor(benchmark::State& state)
|
||||
{
|
||||
while (state.KeepRunning()) {
|
||||
for (auto x = 0; x < 1000; ++x) {
|
||||
prevector<28, unsigned char> t0;
|
||||
prevector<28, unsigned char> t1;
|
||||
t0.resize(28);
|
||||
t1.resize(29);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void PrevectorClear(benchmark::State& state)
|
||||
{
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
for (auto x = 0; x < 1000; ++x) {
|
||||
prevector<28, unsigned char> t0;
|
||||
prevector<28, unsigned char> t1;
|
||||
t0.resize(28);
|
||||
t0.clear();
|
||||
t1.resize(29);
|
||||
t0.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BENCHMARK(PrevectorDestructor);
|
||||
BENCHMARK(PrevectorClear);
|
||||
Reference in New Issue
Block a user