35 #include <gflags/gflags.h>
43 DEFINE_int32(capacity, 64,
"The initial capacity of the hash map");
47 "The chance (0-100) of the CAS operation being called.");
49 "The chance (0-100) of the at operation being called.");
51 "The chance (0-100) of pushBack operation being called.");
53 "The chance (0-100) of popBack operation being called.");
55 "The chance (0-100) of size operation being called.");
58 DEFINE_int32(num_threads, 1,
"The number of executing threads.");
59 DEFINE_int32(execution_time, 5,
"The amount of time to run the tests");
74 #define MACRO_ADD_RATE(TervelOpName) \
75 func_name_[op_codes::TervelOpName] = "" #TervelOpName ; \
76 func_call_rate_[op_codes::TervelOpName] = FLAGS_##TervelOpName##_rate;
85 func_call_count_[i].store(0);
120 void run(int64_t thread_id) {
129 func_call_rate[i] = func_call_rate_[i] + max_rand;
130 max_rand = func_call_rate[i];
131 func_call_count[i] = 0;
135 std::default_random_engine generator;
136 std::uniform_int_distribution<int> distribution(0, max_rand);
137 std::uniform_int_distribution<int> largeValue(0, UINT_MAX);
146 int op = distribution(generator);
147 if (op <= func_call_rate[op_codes::cas]) {
153 int idx = largeValue(generator) % s;
156 func_call_count[op_codes::cas]++;
158 }
else if (op <= func_call_rate[op_codes::at]) {
165 size_t idx = largeValue(generator) % s;
168 func_call_count[op_codes::at]++;
169 }
else if (op <= func_call_rate[op_codes::popBack]) {
172 func_call_count[op_codes::popBack]++;
173 }
else if (op <= func_call_rate[op_codes::pushBack]) {
174 Value temp = largeValue(generator) & (~0x7);
177 func_call_count[op_codes::pushBack]++;
178 }
else if (op <= func_call_rate[op_codes::size]) {
180 func_call_count[op_codes::size]++;
193 res +=
"Test Handler Configuration\n";
194 res +=
"\tThreads:" + std::to_string(
num_threads_) +
"\n";
197 res +=
"\tOperation rates\n";
199 res +=
"\t\t" + func_name_[i] +
": ";
200 res += std::to_string(func_call_rate_[i]) +
"\n";
208 res +=
"-- Test Results--\n";
211 res +=
"Test Class Configuration\n";
215 res +=
"Operation Counts\n";
218 res +=
"\t" + func_name_[i] +
": " +
219 std::to_string(func_call_count_[i].load()) +
"\n";
220 sum += func_call_count_[i].load();
222 res +=
"Total Operations: " + std::to_string(sum) +
"\n";
224 {
int temp = func_call_count_[op_codes::pushBack] - func_call_count_[op_codes::popBack];
225 res +=
"Calculated Size: " + std::to_string(temp) +
"\n";}
231 func_call_count_[i].fetch_add(func_call_count[i]);
#define MACRO_ADD_RATE(TervelOpName)
std::atomic< bool > wait_flag_
Definition: testObject.h:232
TestClass< Value, Value > * test_class_
Definition: testObject.h:226
std::string results()
Definition: testObject.h:206
void destroy()
Definition: testObject.h:116
void detach_thread()
Definition: blank_api.h:43
TestObject()
Definition: testObject.h:89
void attachThread(int threadID)
Definition: testObject.h:101
std::atomic< bool > running_
Definition: testObject.h:229
void run(int64_t thread_id)
Definition: testObject.h:120
bool pop_back(T &value)
Definition: wf_vector_api.h:71
Definition: testObject.h:60
std::string * func_name_
Definition: testObject.h:65
Definition: testObject.h:64
Definition: testObject.h:64
void detachThread(int threadID)
Definition: testObject.h:105
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.
bool cas(size_t idx, T &expValue, T newValue)
Definition: wf_vector_api.h:62
std::atomic< int > ready_count_
Definition: testObject.h:230
void attach_thread()
Definition: blank_api.h:40
size_t push_back(T value)
Definition: wf_vector_api.h:66
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:64
op_codes
Definition: testObject.h:62
uint64_t Value
Definition: testObject.h:59
Definition: testObject.h:64
const int execution_time_
Definition: testObject.h:224
Definition: testObject.h:62
void init()
Definition: testObject.h:113
size_t size()
Definition: blank_api.h:57
std::string toString()
Definition: testObject.h:191
bool at(size_t idx, T &value)
Definition: wf_vector_api.h:58
static const int k_num_functions
Definition: testObject.h:63
Definition: blank_api.h:31
void set_rates()
Definition: testObject.h:70
Definition: testObject.h:64
~TestObject()
Definition: testObject.h:96
void extra_end_signal()
Definition: testObject.h:109
std::string toString()
Definition: blank_api.h:36