13 #include <dhcpsrv/testutils/lease_file_io.h>
28 MemfileLeaseMgrBenchmark() : io4_(
""), io6_(
"") {
36 void SetUp(::benchmark::State
const&)
override {
38 io4_ = LeaseFileIO(getLeaseFilePath(
"leasefile4_0.csv"));
39 io6_ = LeaseFileIO(getLeaseFilePath(
"leasefile6_0.csv"));
42 removeFiles(getLeaseFilePath(
"leasefile4_0.csv"));
43 removeFiles(getLeaseFilePath(
"leasefile6_0.csv"));
49 std::cerr <<
"ERROR: unable to start memfile backend." << std::endl;
55 void SetUp(::benchmark::State& s)
override {
56 ::benchmark::State
const& cs = s;
63 void startBackend(Universe u) {
67 std::cerr <<
"*** ERROR: unable to create instance of the Memfile "
68 <<
"lease database backend." << std::endl;
84 static std::string getConfigString(Universe u) {
86 s <<
"type=memfile " << (u == V4 ?
"universe=4 " :
"universe=6 ")
87 <<
"name=" << getLeaseFilePath(u == V4 ?
"leasefile4_0.csv" :
"leasefile6_0.csv")
98 static std::string getLeaseFilePath(
const std::string& filename) {
100 s << TEST_DATA_BUILDDIR <<
"/" << filename;
109 void removeFiles(
const std::string& base_name)
const {
126 void TearDown(::benchmark::State
const&)
override {
130 std::cerr <<
"WARNING: rollback has failed. This is surprising as "
131 <<
"memfile doesn't support rollback." << std::endl;
137 removeFiles(getLeaseFilePath(
"leasefile4_0.csv"));
138 removeFiles(getLeaseFilePath(
"leasefile6_0.csv"));
141 void TearDown(::benchmark::State& s)
override {
142 ::benchmark::State
const& cs = s;
154 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, insertLeases4)(benchmark::State& state) {
155 const size_t lease_count = state.range(0);
156 while (state.KeepRunning()) {
157 setUp4(state, lease_count);
158 benchInsertLeases4();
163 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, updateLeases4)(benchmark::State& state) {
164 const size_t lease_count = state.range(0);
165 while (state.KeepRunning()) {
166 setUpWithInserts4(state, lease_count);
167 benchUpdateLeases4();
172 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease4_address)(benchmark::State& state) {
173 const size_t lease_count = state.range(0);
174 while (state.KeepRunning()) {
175 setUpWithInserts4(state, lease_count);
176 benchGetLease4_address();
181 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease4_hwaddr)(benchmark::State& state) {
182 const size_t lease_count = state.range(0);
183 while (state.KeepRunning()) {
184 setUpWithInserts4(state, lease_count);
185 benchGetLease4_hwaddr();
191 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease4_hwaddr_subnetid)(benchmark::State& state) {
192 const size_t lease_count = state.range(0);
193 while (state.KeepRunning()) {
194 setUpWithInserts4(state, lease_count);
195 benchGetLease4_hwaddr_subnetid();
200 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease4_clientid)(benchmark::State& state) {
201 const size_t lease_count = state.range(0);
202 while (state.KeepRunning()) {
203 setUpWithInserts4(state, lease_count);
204 benchGetLease4_clientid();
210 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease4_clientid_subnetid)(benchmark::State& state) {
211 const size_t lease_count = state.range(0);
212 while (state.KeepRunning()) {
213 setUpWithInserts4(state, lease_count);
214 benchGetLease4_clientid_subnetid();
219 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getExpiredLeases4)(benchmark::State& state) {
220 const size_t lease_count = state.range(0);
221 while (state.KeepRunning()) {
222 setUpWithInserts4(state, lease_count);
223 benchGetExpiredLeases4();
228 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, insertLeases6)(benchmark::State& state) {
229 const size_t lease_count = state.range(0);
230 while (state.KeepRunning()) {
231 setUp6(state, lease_count);
232 benchInsertLeases6();
237 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, updateLeases6)(benchmark::State& state) {
238 const size_t lease_count = state.range(0);
239 while (state.KeepRunning()) {
240 setUpWithInserts6(state, lease_count);
241 benchUpdateLeases6();
246 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease6_type_address)(benchmark::State& state) {
247 const size_t lease_count = state.range(0);
248 while (state.KeepRunning()) {
249 setUpWithInserts6(state, lease_count);
250 benchGetLease6_type_address();
255 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark::State& state) {
256 const size_t lease_count = state.range(0);
257 while (state.KeepRunning()) {
258 setUpWithInserts6(state, lease_count);
259 benchGetLease6_type_duid_iaid();
265 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
266 (benchmark::State& state) {
267 const size_t lease_count = state.range(0);
268 while (state.KeepRunning()) {
269 setUpWithInserts6(state, lease_count);
270 benchGetLease6_type_duid_iaid_subnetid();
275 BENCHMARK_DEFINE_F(MemfileLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State& state) {
276 const size_t lease_count = state.range(0);
277 while (state.KeepRunning()) {
278 setUpWithInserts6(state, lease_count);
279 benchGetExpiredLeases6();
287 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, insertLeases4)
291 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, updateLeases4)
295 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease4_address)
299 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease4_hwaddr)
304 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease4_hwaddr_subnetid)
308 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease4_clientid)
312 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease4_clientid_subnetid)
316 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getExpiredLeases4)
320 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, insertLeases6)
324 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, updateLeases6)
328 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease6_type_address)
332 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease6_type_duid_iaid)
337 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
341 BENCHMARK_REGISTER_F(MemfileLeaseMgrBenchmark, getExpiredLeases6)
static void destroy()
Destroy lease manager.
LFCFileType
Types of the lease files used by the Lease File Cleanup.
constexpr benchmark::TimeUnit UNIT
A time unit used - all results to be expressed in us (microseconds)
constexpr size_t MAX_LEASE_COUNT
A maximum number of leases used in a benchmark.
A base class for a fixture for specific lease manager benchmarks.
static void create(const std::string &dbaccess)
Create an instance of a lease manager.
static LeaseMgr & instance()
Return current lease manager.
static std::string appendSuffix(const std::string &file_name, const LFCFileType &file_type)
Appends appropriate suffix to the file name.
constexpr size_t MIN_LEASE_COUNT
A minimum number of leases used in a benchmark.