20 #include <pgsql/testutils/pgsql_schema.h>
42 void SetUp(::benchmark::State
const&)
override {
47 HostMgr::addBackend(validPgSQLConnectionString());
49 cerr <<
"ERROR: unable to open database" << endl;
52 hdsptr_ = HostMgr::instance().getHostDataSource();
55 void SetUp(::benchmark::State& s)
override {
56 ::benchmark::State
const& cs = s;
61 void TearDown(::benchmark::State
const&)
override {
65 cerr <<
"WARNING: rollback has failed, this is expected if database"
66 " is opened in read-only mode, continuing..."
69 HostMgr::delBackend(
"postgresql");
74 void TearDown(::benchmark::State& s)
override {
75 ::benchmark::State
const& cs = s;
82 BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, insertHosts)(benchmark::State& state) {
83 const size_t host_count = state.range(0);
84 while (state.KeepRunning()) {
85 setUp(state, host_count);
92 BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, getAll)(benchmark::State& state) {
93 const size_t host_count = state.range(0);
94 while (state.KeepRunning()) {
95 setUpWithInserts(state, host_count);
102 BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, getAllv4Resv)(benchmark::State& state) {
103 const size_t host_count = state.range(0);
104 while (state.KeepRunning()) {
105 setUpWithInserts(state, host_count);
112 BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get4IdentifierSubnetId)(benchmark::State& state) {
113 const size_t host_count = state.range(0);
114 while (state.KeepRunning()) {
115 setUpWithInserts(state, host_count);
116 benchGet4IdentifierSubnetId();
122 BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)(benchmark::State& state) {
123 const size_t host_count = state.range(0);
124 while (state.KeepRunning()) {
125 setUpWithInserts(state, host_count);
126 benchGet4SubnetIdv4Resrv();
132 BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6IdentifierSubnetId)(benchmark::State& state) {
133 const size_t host_count = state.range(0);
134 while (state.KeepRunning()) {
135 setUpWithInserts(state, host_count);
136 benchGet6IdentifierSubnetId();
142 BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6SubnetIdAddr)(benchmark::State& state) {
143 const size_t host_count = state.range(0);
144 while (state.KeepRunning()) {
145 setUpWithInserts(state, host_count);
146 benchGet6SubnetIdAddr();
152 BENCHMARK_DEFINE_F(PgSqlHostDataSourceBenchmark, get6Prefix)(benchmark::State& state) {
153 const size_t host_count = state.range(0);
154 while (state.KeepRunning()) {
155 setUpWithInserts(state, host_count);
162 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, insertHosts)
167 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAll)
172 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, getAllv4Resv)
177 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4IdentifierSubnetId)
182 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get4SubnetIdv4Resrv)
187 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6IdentifierSubnetId)
192 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6SubnetIdAddr)
197 BENCHMARK_REGISTER_F(PgSqlHostDataSourceBenchmark, get6Prefix)
constexpr size_t MIN_HOST_COUNT
A minimum number of leases used in a benchmark.
constexpr benchmark::TimeUnit UNIT
A time unit used - all results to be expressed in us (microseconds)
constexpr size_t MAX_HOST_COUNT
A maximum number of leases used in a benchmark.
Base fixture class for benchmarking host backends.