#include "obj_bencher.h"
#include <iostream>
-#include <fstream>
+#include <fstream>
#include <cerrno>
int ObjBencher::aio_bench(
int operation, int secondsToRun,
- int concurrentios, int object_size, bool cleanup, const char* run_name, bool no_verify) {
+ int concurrentios, int object_size, bool cleanup, const std::string& run_name, bool no_verify) {
if (concurrentios <= 0)
return -EINVAL;
int prevPid = 0;
// default metadata object is used if user does not specify one
- const std::string run_name_meta = (run_name == NULL ? BENCH_LASTRUN_METADATA : std::string(run_name));
+ const std::string run_name_meta = (run_name.empty() ? BENCH_LASTRUN_METADATA : run_name);
//get data from previous write run, if available
if (operation != OP_WRITE) {
return r;
}
-int ObjBencher::clean_up(const char* prefix, int concurrentios, const char* run_name) {
+int ObjBencher::clean_up(const std::string& prefix, int concurrentios, const std::string& run_name) {
int r = 0;
int object_size;
int num_objects;
int prevPid;
// default meta object if user does not specify one
- const std::string run_name_meta = (run_name == NULL ? BENCH_LASTRUN_METADATA : std::string(run_name));
+ const std::string run_name_meta = (run_name.empty() ? BENCH_LASTRUN_METADATA : run_name);
r = fetch_bench_metadata(run_name_meta, &object_size, &num_objects, &prevPid);
if (r < 0) {
// if the metadata file is not found we should try to do a linear search on the prefix
- if (r == -ENOENT && prefix != NULL) {
+ if (r == -ENOENT && prefix != "") {
return clean_up_slow(prefix, concurrentios);
}
else {
virtual ~ObjBencher() {}
int aio_bench(
int operation, int secondsToRun,
- int concurrentios, int op_size, bool cleanup, const char* run_name, bool no_verify=false);
- int clean_up(const char* prefix, int concurrentios, const char* run_name);
+ int concurrentios, int op_size, bool cleanup, const std::string& run_name, bool no_verify=false);
+ int clean_up(const std::string& prefix, int concurrentios, const std::string& run_name);
void set_show_time(bool dt) {
show_time = dt;
}
if (operation == OP_CLEANUP) {
- ret = bencher.clean_up(prefix.c_str(), concurrent_ios, run_name.c_str());
+ ret = bencher.clean_up(prefix, concurrent_ios, run_name);
if (ret != 0)
cerr << "error during cleanup: " << ret << std::endl;
} else {
ret = bencher.aio_bench(operation, seconds,
- concurrent_ios, op_size, cleanup, run_name.c_str());
+ concurrent_ios, op_size, cleanup, run_name);
if (ret != 0) {
cerr << "error during benchmark: " << ret << std::endl;
}