35 #include <gflags/gflags.h>
37 #define __tervel_xstr(s) __tervel_str(s)
38 #define __tervel_str(s) #s
39 #include __tervel_xstr(CONTAINER_FILE)
46 DEFINE_int32(capacity, 64,
"The initial capacity of the container");
50 DEFINE_int32(prefill, 0,
"The number of elements to be initially inserted.");
51 DEFINE_int32(enqueue_rate, 60,
"The percent of insert operations.");
52 DEFINE_int32(dequeue_rate, 40,
"The percent of find operations.");
57 DEFINE_int32(num_threads, 1,
"The number of executing threads.");
58 DEFINE_int32(execution_time, 5,
"The amount of time to run the tests");
75 #define MACRO_ADD_RATE(TervelOpName) \
76 func_name_[op_codes::TervelOpName] = "" #TervelOpName ; \
77 func_call_rate_[op_codes::TervelOpName] = FLAGS_##TervelOpName##_rate; \
78 func_call_count_[op_codes::TervelOpName].store(0);
119 std::default_random_engine generator;
120 std::uniform_int_distribution<uint64_t> largeValue(0, UINT_MAX);
121 for (
int i = 0; i < FLAGS_prefill; i++) {
122 uint64_t x = largeValue(generator) & (~0x3);
130 void run(int64_t thread_id) {
140 func_call_rate[i] = func_call_rate_[i] + max_rand;
141 max_rand = func_call_rate[i];
142 func_call_count[i] = 0;
146 std::default_random_engine generator;
147 std::uniform_int_distribution<int> distribution(0, max_rand);
148 std::uniform_int_distribution<int> largeValue(0, UINT_MAX);
157 int op = distribution(generator);
159 if (op <= func_call_rate[op_codes::enqueue]) {
161 Value x = (thread_id << 56) | ecount;
163 func_call_count[op_codes::enqueue]++;
166 func_call_count[op_codes::failenqueue]++;
168 }
else if (op <= func_call_rate[op_codes::dequeue]) {
171 func_call_count[op_codes::dequeue]++;
173 func_call_count[op_codes::faildequeue]++;
187 res +=
"Test Handler Configuration\n";
188 res +=
"\tThreads:" + std::to_string(
num_threads_) +
"\n";
191 res +=
"\tOperation rates\n";
193 res +=
"\t\t" + func_name_[i] +
": ";
194 res += std::to_string(func_call_rate_[i]) +
"\n";
202 res +=
"-- Test Results--\n";
205 res +=
"Test Class Configuration\n";
209 res +=
"Operation Counts\n";
212 res +=
"\t" + func_name_[i] +
": " +
213 std::to_string(func_call_count_[i].load()) +
"\n";
214 sum += func_call_count_[i].load();
216 res +=
"Total Operations: " + std::to_string(sum) +
"\n";
222 func_call_count_[i].fetch_add(func_call_count[i]);
242 for (i = 0; i < FLAGS_capacity; i++) {
244 assert(res &&
"If this assert fails then the there is an issue with either pushing or determining that it is full");
248 assert(!res &&
"If this assert fails then the there is an issue with either pushing or determining that it is full");
250 for (j = 0; j < FLAGS_capacity; j++) {
252 assert(res &&
"If this assert fails then the there is an issue with either poping or determining that it is not empty");
253 assert(temp==j &&
"If this assert fails then there is an issue with determining the top element");
257 assert(!res &&
"If this assert fails then there is an issue with pop or determining that it is empty");
std::atomic< bool > wait_flag_
Definition: testObject.h:232
TestClass< Value, Value > * test_class_
Definition: testObject.h:226
std::string results()
Definition: testObject.h:200
void destroy()
Definition: testObject.h:126
void detach_thread()
Definition: blank_api.h:43
TestObject()
Definition: testObject.h:86
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:130
Definition: testObject.h:60
void sanity_check()
Definition: testObject.h:238
std::string * func_name_
Definition: testObject.h:65
void detachThread(int threadID)
Definition: testObject.h:105
std::atomic< int > func_call_count_[k_num_functions]
Definition: testObject.h:67
const int32_t FLAGS_failenqueue_rate
Definition: testObject.h:53
DEFINE_int32(capacity, 64,"The initial capacity of the hash map")
Change this when including a new data structure.
const int32_t FLAGS_faildequeue_rate
Definition: testObject.h:54
bool dequeue(T &val)
Definition: linux_API.h:20
#define MACRO_ADD_RATE(TervelOpName)
Definition: testObject.h:65
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
TestClass< Value > * test_class_
Definition: testObject.h:229
void add_results(int func_call_count[k_num_functions])
Definition: testObject.h:217
int * func_call_rate_
Definition: testObject.h:64
op_codes
Definition: testObject.h:62
uint64_t Value
Definition: testObject.h:59
Definition: testObject.h:65
const int execution_time_
Definition: testObject.h:224
Definition: testObject.h:65
Definition: testObject.h:62
void init()
Definition: testObject.h:115
std::string toString()
Definition: testObject.h:185
static const int k_num_functions
Definition: testObject.h:63
Definition: testObject.h:65
bool enqueue(T value)
Definition: linux_API.h:15
void set_rates()
Definition: testObject.h:72
~TestObject()
Definition: testObject.h:96
void extra_end_signal()
Definition: testObject.h:109
std::string toString()
Definition: blank_api.h:36