-MYSQL_CFLAGS=`mysql_config --cflags`
-MYSQL_LDFLAGS=`mysql_config --libs`
CFLAGS=-g -O0 -Wall -pedantic -Wextra
LDFLAGS=-lrt
-SQLITE_CFLAGS=`pkg-config sqlite3 --cflags` $(LDFLAGS)
+MEMFILE_CFLAGS=
+MEMFILE_LDFLAGS=
+
+MYSQL_CFLAGS=`mysql_config --cflags`
+MYSQL_LDFLAGS=`mysql_config --libs`
+
+SQLITE_CFLAGS=`pkg-config sqlite3 --cflags`
SQLITE_LDFLAGS=`pkg-config sqlite3 --libs`
all: mysql_ubench sqlite_ubench memfile_ubench
$(CXX) $< -c $(CFLAGS) $(MYSQL_CFLAGS)
mysql_ubench: mysql_ubench.o benchmark.o
- $(CXX) $< benchmark.o -o mysql_ubench $(CFLAGS) $(MYSQL_CFLAGS) $(MYSQL_LDFLAGS)
+ $(CXX) $< benchmark.o -o mysql_ubench $(CFLAGS) $(MYSQL_CFLAGS) $(LDFLAGS) $(MYSQL_LDFLAGS)
sqlite_ubench.o: sqlite_ubench.cc sqlite_ubench.h
$(CXX) $< -c $(CFLAGS) $(SQLLITE_CFLAGS)
sqlite_ubench: sqlite_ubench.o benchmark.o
- $(CXX) $< benchmark.o -o sqlite_ubench $(CFLAGS) $(SQLITE_CFLAGS) $(SQLITE_LDFLAGS)
+ $(CXX) $< benchmark.o -o sqlite_ubench $(CFLAGS) $(SQLITE_CFLAGS) $(LDFLAGS) $(SQLITE_LDFLAGS)
memfile_ubench.o: memfile_ubench.cc memfile_ubench.h
- $(CXX) $< -c $(CFLAGS) $(SQLLITE_CFLAGS)
+ $(CXX) $< -c $(CFLAGS) $(MEMFILE_CFLAGS)
memfile_ubench: memfile_ubench.o benchmark.o
- $(CXX) $< benchmark.o -o memfile_ubench $(LDFLAGS)
+ $(CXX) $< benchmark.o -o memfile_ubench $(LDFLAGS) $(MEMFILE_LDFLAGS)
clean:
rm -f mysql_ubench sqlite_ubench memfile_ubench *.o
dhcp-perf-guide.xml
dhcp-perf-guide.pdf: dhcp-perf-guide.xml
- docbook2pdf $<
\ No newline at end of file
+ docbook2pdf $<
}
break;
case 's':
- if (!strcasecmp(optarg, "yes") || !strcmp(optarg,"1")) {
+ if (!strcasecmp(optarg, "yes") || !strcmp(optarg, "1")) {
Sync_ = true;
} else {
Sync_ = false;
}
break;
case 'v':
- if (!strcasecmp(optarg, "yes") || !strcmp(optarg,"1")) {
+ if (!strcasecmp(optarg, "yes") || !strcmp(optarg, "1")) {
Verbose_ = true;
} else {
Verbose_ = false;
int uBenchmark::run() {
- cout << "Starting test. Parameters: " << endl
- << "Number of iterations :" << Num_ << endl
- << "Sync/async :" << (Sync_?"sync":"async") << endl
- << "Verbose :" << (Verbose_?"verbose":"quiet") << endl
- << "Database name :" << DBName_ << endl
- << "MySQL hostname :" << Hostname_ << endl
- << "MySQL username :" << User_ << endl
- << "MySQL password :" << Passwd_ << endl << endl;
+ cout << "Starting test. Parameters:" << endl
+ << "Number of iterations : " << Num_ << endl
+ << "Sync/async : " << (Sync_ ? "sync" : "async") << endl
+ << "Verbose : " << (Verbose_ ? "verbose" : "quiet") << endl
+ << "Database name : " << DBName_ << endl
+ << "MySQL hostname : " << Hostname_ << endl
+ << "MySQL username : " << User_ << endl
+ << "MySQL password : " << Passwd_ << endl << endl;
srandom(time(NULL));
void memfile_uBenchmark::connect() {
try {
LeaseMgr_ = new memfile_LeaseMgr(Filename_, Sync_);
-
} catch (const std::string& e) {
failure(e.c_str());
}
throw "No LeaseMgr instantiated.";
}
- uint32_t addr = BASE_ADDR4; // Let's start with 1.0.0.0 address
- const uint8_t hwaddr_len = 20; // not a real field
+ uint32_t addr = BASE_ADDR4; // Let's start with 1.0.0.0 address
+ const uint8_t hwaddr_len = 20; // Not a real field
char hwaddr_tmp[hwaddr_len];
const uint8_t client_id_len = 128;
char client_id_tmp[client_id_len];
- uint32_t valid_lft = 1000; // we can use the same value for all leases
- uint32_t recycle_time = 0; // not supported in any foresable future,
- // so keep this as 0
- time_t cltt = time(NULL); // timestamp
- uint32_t pool_id = 0; // let's use pools 0-99
- bool fixed = false; //
- string hostname("foo"); // will generate it dynamically
- bool fqdn_fwd = true; // let's pretend to do AAAA update
- bool fqdn_rev = true; // let's pretend to do PTR update
+ uint32_t valid_lft = 1000; // We can use the same value for all leases
+ uint32_t recycle_time = 0; // Not supported in any foreseeable future,
+ // so keep this as 0
+ time_t cltt = time(NULL); // Timestamp
+ uint32_t pool_id = 0; // Let's use pools 0-99
+ bool fixed = false;
+ string hostname("foo"); // Will generate it dynamically
+ bool fqdn_fwd = true; // Let's pretend to do AAAA update
+ bool fqdn_rev = true; // Let's pretend to do PTR update
printf("CREATE: ");
- // while we could put the data directly into vector, I would like to
+ // While we could put the data directly into vector, I would like to
// keep the code as similar to other benchmarks as possible
for (uint8_t i = 0; i < hwaddr_len; i++) {
hwaddr_tmp[i] = 65 + i;
}
- vector<uint8_t> hwaddr(hwaddr_tmp, hwaddr_tmp+19);
+ vector<uint8_t> hwaddr(hwaddr_tmp, hwaddr_tmp + 19);
for (uint8_t i = 0; i < client_id_len; i++) {
client_id_tmp[i] = 33 + i;
}
- vector<uint8_t> client_id(client_id_tmp, client_id_tmp+19);
+ vector<uint8_t> client_id(client_id_tmp, client_id_tmp + 19);
for (uint32_t i = 0; i < Num_; i++) {
throw "No LeaseMgr instantiated.";
}
- // this formula should roughly find something a lease in 90% cases
+ // This formula should roughly find something a lease in 90% cases
float hitRatio = 0.5;
printf("RETRIEVE: ");
for (uint32_t i = 0; i < Num_; i++) {
-
uint32_t x = BASE_ADDR4 + random() % int(Num_ / hitRatio);
Lease4Ptr lease = LeaseMgr_->getLease(x);
uint32_t addr = BASE_ADDR4; // Let's start with 1.0.0.0 address
char hwaddr[20];
- uint8_t hwaddr_len = 20; // not a real field
+ uint8_t hwaddr_len = 20; // Not a real field
char client_id[128];
uint8_t client_id_len = 128;
- uint32_t valid_lft = 1000; // we can use the same value for all leases
- uint32_t recycle_time = 0; // not supported in any foresable future,
- // so keep this as 0
- string cltt = "now()"; // timestamp
- uint32_t pool_id = 0; // let's use pools 0-99
- bool fixed = false; //
- string hostname("foo"); // will generate it dynamically
- bool fqdn_fwd = true; // let's pretend to do AAAA update
- bool fqdn_rev = true; // let's pretend to do PTR update
+ uint32_t valid_lft = 1000; // We can use the same value for all leases
+ uint32_t recycle_time = 0; // not supported in any foresable future,
+ // so keep this as 0
+ string cltt = "now()"; // Timestamp
+ uint32_t pool_id = 0; // Let's use pools 0-99
+ bool fixed = false;
+ string hostname("foo"); // Will generate it dynamically
+ bool fqdn_fwd = true; // Let's pretend to do AAAA update
+ bool fqdn_rev = true; // Let's pretend to do PTR update
printf("CREATE: ");
sprintf(query, "UPDATE lease4 SET valid_lft=1002, cltt=now() WHERE addr=%d", x);
mysql_real_query(Conn_, query, strlen(query));
- if (Verbose_)
+ if (Verbose_) {
printf(".");
+ }
}
printf("\n");
int main(int argc, char * const argv[]) {
- const char * hostname ="localhost"; // -m (MySQL server)
- const char * user = "root"; // -u
- const char * passwd = "secret"; // -p
- const char * dbname = "kea"; // -f
- uint32_t num = 100; // -n
- bool sync = true; // -s
- bool verbose = true; // -v
+ const char* hostname ="localhost"; // -m (MySQL server)
+ const char* user = "root"; // -u
+ const char* passwd = "secret"; // -p
+ const char* dbname = "kea"; // -f
+ uint32_t num = 100; // -n
+ bool sync = true; // -s
+ bool verbose = true; // -v
MySQL_uBenchmark bench(hostname, user, passwd, dbname, num, sync, verbose);
- bench.parseCmdline(argc, argv);
+ bench.parseCmdline(argc, argv);
int result = bench.run();
protected:
void failure(const char* operation);
- MYSQL * Conn_;
+ MYSQL* Conn_;
};
throw "SQLite connection is closed.";
}
- uint32_t addr = BASE_ADDR4; // Let's start with 1.0.0.0 address
- const uint8_t hwaddr_len = 20; // not a real field
+ uint32_t addr = BASE_ADDR4; // Let's start with 1.0.0.0 address
+ const uint8_t hwaddr_len = 20; // Not a real field
char hwaddr[hwaddr_len];
const uint8_t client_id_len = 128;
char client_id[client_id_len];
- uint32_t valid_lft = 1000; // we can use the same value for all leases
- uint32_t recycle_time = 0; // not supported in any foresable future,
- // so keep this as 0
- string cltt = "now"; // timestamp
- uint32_t pool_id = 0; // let's use pools 0-99
- bool fixed = false; //
- string hostname("foo"); // will generate it dynamically
- bool fqdn_fwd = true; // let's pretend to do AAAA update
- bool fqdn_rev = true; // let's pretend to do PTR update
+ uint32_t valid_lft = 1000; // We can use the same value for all leases
+ uint32_t recycle_time = 0; // Not supported in any foresable future,
+ // so keep this as 0
+ string cltt = "now"; // Timestamp
+ uint32_t pool_id = 0; // Let's use pools 0-99
+ bool fixed = false;
+ string hostname("foo"); // Will generate it dynamically
+ bool fqdn_fwd = true; // Let's pretend to do AAAA update
+ bool fqdn_rev = true; // Let's pretend to do PTR update
printf("CREATE: ");
cltt << "2012-07-11 15:43:" << (i % 60);
addr++;
- char * errorMsg = NULL;
+ char* errorMsg = NULL;
// the first address is 1.0.0.0.
char query[2000];
printf("\n");
}
-static int search_callback(void *counter, int /*argc*/, char **/*argv*/,
- char **/*azColName*/){
+static int search_callback(void *counter, int /*argc*/, char** /*argv*/,
+ char** /*azColName*/){
- int * cnt = static_cast<int*>(counter);
+ int* cnt = static_cast<int*>(counter);
(*cnt)++;
#if 0
uint32_t x = BASE_ADDR4 + random() % int(Num_ / hitRatio);
- char * errorMsg = NULL;
+ char* errorMsg = NULL;
int cnt = 0;
uint32_t x = BASE_ADDR4 + random() % Num_;
- char * errorMsg = NULL;
+ char* errorMsg = NULL;
char query[2000];
sprintf(query, "UPDATE lease4 SET valid_lft=1002, cltt='now' WHERE addr=%d", x);
for (uint32_t i = 0; i < Num_; i++) {
uint32_t x = BASE_ADDR4 + i;
- char * errorMsg = NULL;
+ char* errorMsg = NULL;
char query[2000];
sprintf(query, "DELETE FROM lease4 WHERE addr=%d", x);
-int main(int argc, char * const argv[]) {
+int main(int argc, char* const argv[]) {
- const char * filename = "sqlite.db";
+ const char* filename = "sqlite.db";
uint32_t num = 100;
bool sync = true;
bool verbose = true;