Kea 1.5.0
cql_lease_mgr_benchmark.cc
Go to the documentation of this file.
1// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
2// Copyright (C) 2017 Deutsche Telekom AG.
3//
4// Authors: Andrei Pavel <andrei.pavel@qualitance.com>
5//
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18#include <config.h>
19
23#include <dhcpsrv/testutils/cql_schema.h>
24
25using namespace isc::dhcp::bench;
26using namespace isc::dhcp::test;
27using namespace isc::dhcp;
28using namespace std;
29
30namespace {
31
33class CqlLeaseMgrBenchmark : public GenericLeaseMgrBenchmark {
34public:
38 void SetUp(::benchmark::State const&) override {
39 destroyCqlSchema(false, true);
40 createCqlSchema(false, true);
41 try {
43 LeaseMgrFactory::create(validCqlConnectionString());
44 } catch (...) {
45 cerr << "ERROR: unable to open database" << endl;
46 throw;
47 }
48 lmptr_ = &(LeaseMgrFactory::instance());
49 }
50
52 void TearDown(::benchmark::State const&) override {
53 try {
54 lmptr_->rollback();
55 } catch (...) {
56 cerr << "WARNING: rollback has failed, this is expected if database"
57 " is opened in read-only mode, continuing..."
58 << endl;
59 }
61 destroyCqlSchema(false, true);
62 }
63};
64
65// Defines a benchmark that measures IPv4 leases insertion.
66BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, insertLeases4)(benchmark::State& state) {
67 const size_t lease_count = state.range(0);
68 while (state.KeepRunning()) {
69 setUp4(state, lease_count);
70 benchInsertLeases4();
71 }
72}
73
74// Defines a benchmark that measures IPv4 leases update.
75BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, updateLeases4)(benchmark::State& state) {
76 const size_t lease_count = state.range(0);
77 while (state.KeepRunning()) {
78 setUpWithInserts4(state, lease_count);
79 benchUpdateLeases4();
80 }
81}
82
83// Defines a benchmark that measures IPv4 leases retrieval by address.
84BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_address)(benchmark::State& state) {
85 const size_t lease_count = state.range(0);
86 while (state.KeepRunning()) {
87 setUpWithInserts4(state, lease_count);
88 benchGetLease4_address();
89 }
90}
91
92// Defines a benchmark that measures IPv4 leases retrieval by hardware address.
93BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_hwaddr)(benchmark::State& state) {
94 const size_t lease_count = state.range(0);
95 while (state.KeepRunning()) {
96 setUpWithInserts4(state, lease_count);
97 benchGetLease4_hwaddr();
98 }
99}
100
101// Defines a benchmark that measures IPv4 leases retrieval by hardware address
102// and subnet-id.
103BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_hwaddr_subnetid)(benchmark::State& state) {
104 const size_t lease_count = state.range(0);
105 while (state.KeepRunning()) {
106 setUpWithInserts4(state, lease_count);
107 benchGetLease4_hwaddr_subnetid();
108 }
109}
110
111// Defines a benchmark that measures IPv4 leases retrieval by client-id.
112BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_clientid)(benchmark::State& state) {
113 const size_t lease_count = state.range(0);
114 while (state.KeepRunning()) {
115 setUpWithInserts4(state, lease_count);
116 benchGetLease4_clientid();
117 }
118}
119
120// Defines a benchmark that measures IPv4 leases retrieval by client-id and
121// subnet-id.
122BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease4_clientid_subnetid)(benchmark::State& state) {
123 const size_t lease_count = state.range(0);
124 while (state.KeepRunning()) {
125 setUpWithInserts4(state, lease_count);
126 benchGetLease4_clientid_subnetid();
127 }
128}
129
130// Defines a benchmark that measures retrieval of expired IPv4 leases.
131BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getExpiredLeases4)(benchmark::State& state) {
132 const size_t lease_count = state.range(0);
133 while (state.KeepRunning()) {
134 setUpWithInserts4(state, lease_count);
135 benchGetExpiredLeases4();
136 }
137}
138
139// Defines a benchmark that measures IPv6 leases insertion.
140BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, insertLeases6)(benchmark::State& state) {
141 const size_t lease_count = state.range(0);
142 while (state.KeepRunning()) {
143 setUp6(state, lease_count);
144 benchInsertLeases6();
145 }
146}
147
148// Defines a benchmark that measures IPv6 leases update.
149BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, updateLeases6)(benchmark::State& state) {
150 const size_t lease_count = state.range(0);
151 while (state.KeepRunning()) {
152 setUpWithInserts6(state, lease_count);
153 benchUpdateLeases6();
154 }
155}
156
157// Defines a benchmark that measures IPv6 leases retrieval by type and address.
158BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease6_type_address)(benchmark::State& state) {
159 const size_t lease_count = state.range(0);
160 while (state.KeepRunning()) {
161 setUpWithInserts6(state, lease_count);
162 benchGetLease6_type_address();
163 }
164}
165
166// Defines a benchmark that measures IPv6 leases retrieval by type, duid and iaid.
167BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid)(benchmark::State& state) {
168 const size_t lease_count = state.range(0);
169 while (state.KeepRunning()) {
170 setUpWithInserts6(state, lease_count);
171 benchGetLease6_type_duid_iaid();
172 }
173}
174
175// Defines a benchmark that measures IPv6 leases retrieval by lease type, duid, iaid
176// and subnet-id.
177BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
178 (benchmark::State& state) {
179 const size_t lease_count = state.range(0);
180 while (state.KeepRunning()) {
181 setUpWithInserts6(state, lease_count);
182 benchGetLease6_type_duid_iaid_subnetid();
183 }
184}
185
186// Defines a benchmark that measures retrieval of expired IPv6 leases.
187BENCHMARK_DEFINE_F(CqlLeaseMgrBenchmark, getExpiredLeases6)(benchmark::State& state) {
188 const size_t lease_count = state.range(0);
189 while (state.KeepRunning()) {
190 setUpWithInserts6(state, lease_count);
191 benchGetExpiredLeases6();
192 }
193}
194
195
198
200BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, insertLeases4)
201 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
202
204BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, updateLeases4)
205 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
206
208BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_address)
209 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
210
212BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_hwaddr)
213 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
214
217BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_hwaddr_subnetid)
218 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
219
221BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_clientid)
222 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
223
225BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease4_clientid_subnetid)
226 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
227
229BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getExpiredLeases4)
230 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
231
233BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, insertLeases6)
234 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
235
237BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, updateLeases6)
238 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
239
241BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease6_type_address)
242 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
243
245BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid)
246 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
247
250BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getLease6_type_duid_iaid_subnetid)
251 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
252
254BENCHMARK_REGISTER_F(CqlLeaseMgrBenchmark, getExpiredLeases6)
255 ->Range(MIN_LEASE_COUNT, MAX_LEASE_COUNT)->Unit(UNIT);
256
257} // namespace
static void create(const std::string &dbaccess)
Create an instance of a lease manager.
static void destroy()
Destroy lease manager.
static LeaseMgr & instance()
Return current lease manager.
A base class for a fixture for specific lease manager benchmarks.
constexpr benchmark::TimeUnit UNIT
A time unit used - all results to be expressed in us (microseconds)
Definition: parameters.h:35
constexpr size_t MIN_LEASE_COUNT
A minimum number of leases used in a benchmark.
Definition: parameters.h:25
constexpr size_t MAX_LEASE_COUNT
A maximum number of leases used in a benchmark.
Definition: parameters.h:27