35 #include <gflags/gflags.h>
43 DEFINE_int32(capacity, 64,
"The initial capacity of the hash map");
47 DEFINE_int32(prefill, 0,
"The number of elements to be initially inserted.");
48 DEFINE_int32(insert_rate, 25,
"The percent of insert operations.");
49 DEFINE_int32(find_rate, 25,
"The percent of find operations.");
50 DEFINE_int32(update_rate, 25,
"The percent of update operations.");
51 DEFINE_int32(remove_rate, 25,
"The percent of remove operations.");
54 DEFINE_int32(num_threads, 1,
"The number of executing threads.");
55 DEFINE_int32(execution_time, 5,
"The amount of time to run the tests");
71 #define MACRO_ADD_RATE(TervelOpName) \
72 func_name_[op_codes::TervelOpName] = "" #TervelOpName ; \
73 func_call_rate_[op_codes::TervelOpName] = FLAGS_##TervelOpName##_rate;
81 func_call_count_[i].store(0);
112 std::default_random_engine generator;
113 std::uniform_int_distribution<uint64_t> largeValue(0, UINT_MAX);
114 for (
int i = 0; i < FLAGS_prefill; i++) {
115 uint64_t x = largeValue(generator) & (~0xF);
116 uint64_t y = largeValue(generator) & (~0xF);
124 void run(int64_t thread_id) {
133 func_call_rate[i] = func_call_rate_[i] + max_rand;
134 max_rand = func_call_rate[i];
135 func_call_count[i] = 0;
139 std::default_random_engine generator;
140 std::uniform_int_distribution<int> distribution(0, max_rand);
141 std::uniform_int_distribution<int> largeValue(0, UINT_MAX);
150 int op = distribution(generator);
151 uint64_t key = largeValue(generator) & (~0xF);
152 uint64_t temp = largeValue(generator) & (~0xF);
154 if (op <= func_call_rate[op_codes::find]) {
157 func_call_count[op_codes::find]++;
158 }
else if (op <= func_call_rate[op_codes::insert]) {
161 func_call_count[op_codes::insert]++;
162 }
else if (op <= func_call_rate[op_codes::update]) {
166 func_call_count[op_codes::update]++;
167 }
else if (op <= func_call_rate[op_codes::remove]) {
170 func_call_count[op_codes::remove]++;
183 res +=
"Test Handler Configuration\n";
184 res +=
"\tThreads:" + std::to_string(
num_threads_) +
"\n";
187 res +=
"\tOperation rates\n";
189 res +=
"\t\t" + func_name_[i] +
": ";
190 res += std::to_string(func_call_rate_[i]) +
"\n";
198 res +=
"-- Test Results--\n";
201 res +=
"Test Class Configuration\n";
205 res +=
"Operation Counts\n";
208 res +=
"\t" + func_name_[i] +
": " +
209 std::to_string(func_call_count_[i].load()) +
"\n";
210 sum += func_call_count_[i].load();
212 res +=
"Total Operations: " + std::to_string(sum) +
"\n";
219 func_call_count_[i].fetch_add(func_call_count[i]);
std::atomic< bool > wait_flag_
Definition: testObject.h:232
TestClass< Value, Value > * test_class_
Definition: testObject.h:226
std::string results()
Definition: testObject.h:196
Definition: testObject.h:62
void destroy()
Definition: testObject.h:120
void detach_thread()
Definition: blank_api.h:43
TestObject()
Definition: testObject.h:85
void attachThread(int threadID)
Definition: testObject.h:98
std::atomic< bool > running_
Definition: testObject.h:229
void run(int64_t thread_id)
Definition: testObject.h:124
Definition: testObject.h:60
bool insert(Key key, Value value)
Definition: blank_api.h:48
std::string * func_name_
Definition: testObject.h:65
void detachThread(int threadID)
Definition: testObject.h:102
std::atomic< int > func_call_count_[k_num_functions]
Definition: testObject.h:67
DEFINE_int32(capacity, 64,"The initial capacity of the hash map")
Change this when including a new data structure.
std::atomic< int > ready_count_
Definition: testObject.h:230
void attach_thread()
Definition: blank_api.h:40
const int num_threads_
Definition: testObject.h:223
void add_results(int func_call_count[k_num_functions])
Definition: testObject.h:217
int * func_call_rate_
Definition: testObject.h:64
Definition: testObject.h:62
bool update(Key key, Value &value_expected, Value value_new)
Definition: blank_api.h:51
op_codes
Definition: testObject.h:62
uint64_t Value
Definition: testObject.h:59
bool remove(Key key)
Definition: blank_api.h:54
const int execution_time_
Definition: testObject.h:224
Definition: testObject.h:62
void init()
Definition: testObject.h:110
size_t size()
Definition: blank_api.h:57
bool find(Key key, Value &value)
Definition: blank_api.h:45
std::string toString()
Definition: testObject.h:181
static const int k_num_functions
Definition: testObject.h:63
#define MACRO_ADD_RATE(TervelOpName)
Definition: testObject.h:62
void set_rates()
Definition: testObject.h:68
~TestObject()
Definition: testObject.h:93
void extra_end_signal()
Definition: testObject.h:106
std::string toString()
Definition: blank_api.h:36