1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
crate::ix!();
//-------------------------------------------[.cpp/bitcoin/src/bench/addrman.cpp]
/* ------------------- Benchmarks ------------------- */
#[bench]
fn addr_man_add(b: &mut Bencher) {
todo!();
/*
CreateAddresses();
bench.run([&] {
AddrMan addrman{/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 0};
AddAddressesToAddrMan(addrman);
});
*/
}
#[bench]
fn addr_man_select(b: &mut Bencher) {
todo!();
/*
AddrMan addrman(/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 0);
FillAddrMan(addrman);
bench.run([&] {
const auto& address = addrman.Select();
assert(address.first.GetPort() > 0);
});
*/
}
#[bench]
fn addr_man_get_addr(b: &mut Bencher) {
todo!();
/*
AddrMan addrman(/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 0);
FillAddrMan(addrman);
bench.run([&] {
const auto& addresses = addrman.GetAddr(/* max_addresses */ 2500, /* max_pct */ 23, /* network */ std::nullopt);
assert(addresses.size() > 0);
});
*/
}
#[bench]
fn addr_man_add_then_good(b: &mut Bencher) {
let mark_some_as_good = |addrman: &mut AddrMan| {
for source_i in 0..num_sources {
for addr_i in 0..num_addresses_per_source {
addrman.good(g_addresses[source_i][addr_i]);
}
}
};
todo!();
/*
CreateAddresses();
bench.run([&] {
// To make the benchmark independent of the number of evaluations, we always prepare a new addrman.
// This is necessary because AddrMan::Good() method modifies the object, affecting the timing of subsequent calls
// to the same method and we want to do the same amount of work in every loop iteration.
//
// This has some overhead (exactly the result of AddrManAdd benchmark), but that overhead is constant so improvements in
// AddrMan::Good() will still be noticeable.
AddrMan addrman(/* asmap */ std::vector<bool>(), /* deterministic */ false, /* consistency_check_ratio */ 0);
AddAddressesToAddrMan(addrman);
markSomeAsGood(addrman);
});
*/
}