aboutsummaryrefslogtreecommitdiff
path: root/src/bench
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2021-07-23 10:48:34 +0100
committerJohn Newbery <john@johnnewbery.com>2021-08-05 17:10:30 +0100
commitfa9710f62c29c7f8d71c9f281001c9b5e70946bf (patch)
tree25117f2104f8d4a848e3760f3d02f76cef828faa /src/bench
parentee458d84fc187d69f002ebead6fccc4f4f9c0744 (diff)
[addrman] Add deterministic argument to CAddrMan ctor
Removes the need for tests to update nKey and insecure_rand after constructing a CAddrMan.
Diffstat (limited to 'src/bench')
-rw-r--r--src/bench/addrman.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/bench/addrman.cpp b/src/bench/addrman.cpp
index b7bd8a3261..e1175e44ec 100644
--- a/src/bench/addrman.cpp
+++ b/src/bench/addrman.cpp
@@ -72,7 +72,7 @@ static void AddrManAdd(benchmark::Bench& bench)
{
CreateAddresses();
- CAddrMan addrman;
+ CAddrMan addrman(/* deterministic */ false);
bench.run([&] {
AddAddressesToAddrMan(addrman);
@@ -82,7 +82,7 @@ static void AddrManAdd(benchmark::Bench& bench)
static void AddrManSelect(benchmark::Bench& bench)
{
- CAddrMan addrman;
+ CAddrMan addrman(/* deterministic */ false);
FillAddrMan(addrman);
@@ -94,7 +94,7 @@ static void AddrManSelect(benchmark::Bench& bench)
static void AddrManGetAddr(benchmark::Bench& bench)
{
- CAddrMan addrman;
+ CAddrMan addrman(/* deterministic */ false);
FillAddrMan(addrman);
@@ -112,10 +112,12 @@ static void AddrManGood(benchmark::Bench& bench)
* we want to do the same amount of work in every loop iteration. */
bench.epochs(5).epochIterations(1);
+ const size_t addrman_count{bench.epochs() * bench.epochIterations()};
- std::vector<CAddrMan> addrmans(bench.epochs() * bench.epochIterations());
- for (auto& addrman : addrmans) {
- FillAddrMan(addrman);
+ std::vector<std::unique_ptr<CAddrMan>> addrmans(addrman_count);
+ for (size_t i{0}; i < addrman_count; ++i) {
+ addrmans[i] = std::make_unique<CAddrMan>(/* deterministic */ false);
+ FillAddrMan(*addrmans[i]);
}
auto markSomeAsGood = [](CAddrMan& addrman) {
@@ -130,7 +132,7 @@ static void AddrManGood(benchmark::Bench& bench)
uint64_t i = 0;
bench.run([&] {
- markSomeAsGood(addrmans.at(i));
+ markSomeAsGood(*addrmans.at(i));
++i;
});
}