#include <functional>
int main(){
- int sizes[]= { 16000, 32000, 64000, 120000, 1600000, 2000000, 2500000, 3500000, 150000000, 250000000, 350000000, 500000000};
- int loops[]= { 6000, 6000, 6000, 6000, 1000, 1000, 1000, 1000, 50, 50, 25, 25};
- int exp_len[]= { 2000, 2000, 2000, 2000, 250, 250, 250, 250, 10, 10, 5, 5};
+ int sizes[]= { 16000, 32000, 64000, 120000, 1600000, 2000000, 2500000, 3500000, 150000000, 250000000, 350000000, 500000000};
+ int f_loops[]= { 70000, 50000, 30000, 10000, 1000, 1000, 1000, 1000, 7, 7, 5, 3};
+ int t_loops[]= { 200000, 150000, 100000, 70000, 5000, 5000, 5000, 5000, 50, 50, 50, 50};
+ int exp_len[]= { 15, 15, 15, 15, 5, 5, 5, 5, 5, 5, 5, 5};
+ int nd_loops[]= { 250000, 150000, 100000, 100000, 10000, 1000, 1000, 1000, 100, 100, 100, 100};
const char charset[] = "aAaAaAaAAAaaaaAAAAaaaaAAAAAAaaaAAaaa";
- std::string labels[] = {"\x1B[33m shuftiExec Benchmarks(kbytes) \x1B[0m\n", "\x1B[33m rshuftiExec Benchmarks(kbytes) \x1B[0m\n",
- "\x1B[33m truffleExec Benchmarks(kbytes) \x1B[0m\n", "\x1B[33m rtruffleExec Benchmarks(kbytes) \x1B[0m\n",
- "\x1B[33m shuftiExec Benchmarks(Mbytes) \x1B[0m\n", "\x1B[33m rhuftiExec Benchmarks(Mbytes) \x1B[0m\n",
- "\x1B[33m truffleExec Benchmarks(Mbytes) \x1B[0m\n", "\x1B[33m rtruffleExec Benchmarks(Mbytes) \x1B[0m\n",
- "\x1B[33m shuftiExec Benchmarks(Gbytes) \x1B[0m\n", "\x1B[33m rhuftiExec Benchmarks(Gbytes) \x1B[0m\n",
- "\x1B[33m truffleExec Benchmarks(Gbytes) \x1B[0m\n", "\x1B[33m rtruffleExec Benchmarks(Gbytes) \x1B[0m\n"
+ std::string labels[] = {"\x1B[33m Benchmarks(kbytes) \x1B[0m\n", "\x1B[33m Benchmarks(kbytes) \x1B[0m\n",
+ "\x1B[33m Benchmarks(kbytes) \x1B[0m\n", "\x1B[33m Benchmarks(kbytes) \x1B[0m\n",
+ "\x1B[33m Benchmarks(Mbytes) \x1B[0m\n", "\x1B[33m Benchmarks(Mbytes) \x1B[0m\n",
+ "\x1B[33m Benchmarks(Mbytes) \x1B[0m\n", "\x1B[33m Benchmarks(Mbytes) \x1B[0m\n",
+ "\x1B[33m Benchmarks(Gbytes) \x1B[0m\n", "\x1B[33m Benchmarks(Gbytes) \x1B[0m\n",
+ "\x1B[33m Benchmarks(Gbytes) \x1B[0m\n", "\x1B[33m Benchmarks(Gbytes) \x1B[0m\n"
};
+
std::function<void(int,int,int,bool)> functions[] = { shufti_benchmarks, rshufti_benchmarks, truffle_benchmarks, rtruffle_benchmarks };
- for (int i=0; i<12; i++) {
+ for (int i=11; i<12; i++) {
std::cout << labels[i];
for(int j=0; j<4; j++){
- functions[j](sizes[i],loops[i],exp_len[i],false);
- functions[j](sizes[i],loops[i],exp_len[i],true);
+ functions[j](sizes[i],f_loops[i],exp_len[i],false);
+ functions[j](sizes[i],t_loops[i],exp_len[i],true);
}
}
for(int i=0; i<12; i++){
str[char_len] = charset[key];
str[char_len + 1] = '\0';
}
- noodle_benchmarks(sizes[i], loops[i], str,char_len,0);
+ noodle_benchmarks(sizes[i], nd_loops[i], str,char_len,0);
delete [] str;
}
}
ctxt.clear();
u8 *data = new u8[size];
memset(data, 'a', size);
- double total_sec = 0;
+ long double total_sec = 0;
+ long double trans_size = 0;
long double bw = 0;
u32 id = 1000;
ue2::hwlmLiteral lit(std::string(lit_str, lit_len), nocase, id);
noodExec(n.get(), data, size, 0, hlmSimpleCallback, &scratch);
}
auto end = std::chrono::steady_clock::now();
- total_sec += std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
- /*average time*/
- total_sec /= M;
- double mb_size = (double) size / 1048576;
- bw = mb_size / total_sec;
+ total_sec += std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
+ /*calculate transferred size*/
+ trans_size = size * M;
+ /*convert to sec*/
+ bw = trans_size / total_sec;
+ /*convert to MB/s*/
+ bw /=1048576;
+ /*covert average time to μs*/
+ long double ms = total_sec * 1000000;
std::cout << "\x1B[35m Case with match in random pos and size: "<< size <<" lit_len: "<< lit_len <<" nocase: "<< (int)nocase
- << "\x1B[36m noodExec elapsetime: \x1B[0m" << total_sec << " (μs) \x1B[36m bandwidth: \x1B[0m" << bw <<" (MB/μs)" << std::endl;
+ << "\x1B[36m noodExec elapsetime: \x1B[0m" << (ms/M) << " (μs) \x1B[36m bandwidth: \x1B[0m" << bw <<" (MB/s)" << std::endl;
delete [] data;
}
\ No newline at end of file
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
u8 *kt1 = new u8[size];
memset(kt1,'b',size);
- double total_sec = 0;
- double bw = 0;
+ long double total_sec = 0;
+ long double trans_size = 0;
+ long double bw = 0;
if (has_match){
int pos = 0;
for(int j=0; j<M; j++){
act_size += res - kt1;
}
auto end = std::chrono::steady_clock::now();
- double dt = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
- /*average time*/
- dt /= loops;
+ long double dt = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
total_sec += dt;
- /*average size*/
- act_size /= loops;
- double mb_size = (double) act_size / 1048576;
- bw += mb_size / dt;
+ /*calculate transferred size*/
+ trans_size += act_size * loops;
+ /*calculate bandwidth*/
+ bw += trans_size / total_sec;
+ /*convert to MB/s*/
+ bw += bw / 1048576;
+ /*calculte average time*/
+ total_sec /= loops;
}
total_sec /= M;
bw /= M;
- std::cout << "\x1B[35m Case with match in random pos and size: " << real_size << " for " << loops <<" loops ("
- << M << " random possisions checked): \x1B[36m shuftiExec elapsetime: \x1B[0m" << (total_sec)
- << " (μs) \x1B[36m bandwidth: \x1B[0m" << bw <<" (MB/μs)"<<std::endl;
+ /*covert average time to μs*/
+ long double ms = total_sec * 1000000;
+ std::cout << "\x1B[35m Case with match in random pos and size: " << real_size << " for " << loops<<" loops ("
+ << M << " random possisions checked): \x1B[36m shuftiExec elapsetime: \x1B[0m" << (ms/M)
+ <<" (μs) \x1B[36m bandwidth: \x1B[0m" << bw <<" (MB/s)"<<std::endl;
} else {
auto start = std::chrono::steady_clock::now();
for (int i = 0; i < loops; i++) {
shuftiExec(lo, hi, kt1, kt1 + size);
}
auto end = std::chrono::steady_clock::now();
- total_sec += std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
- /*average time*/
- total_sec /= loops;
- double mb_size = (double) size / 1048576;
- mb_size /= loops;
- bw = mb_size / total_sec;
+ total_sec += std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
+ /*calculate transferred size*/
+ trans_size = size * loops ;
+ /*calculate bandwidth*/
+ bw = trans_size / total_sec;
+ /*convert to MB/s*/
+ bw /=1048576;
+ /*covert average time to μs*/
+ long double ms = total_sec * 1000000;
std::cout<<"\x1B[35m Case with no match in random pos and size: "<<real_size<<" for "<<loops<<" loops:"
- <<"\x1B[36m shuftiExec elapsetime: \x1B[0m"<<(total_sec)<<" (μs) \x1B[36m bandwidth: \x1B[0m"<< bw <<" (MB/μs)"<<std::endl;
+ <<"\x1B[36m shuftiExec elapsetime: \x1B[0m"<<(ms/loops)<<" (μs) \x1B[36m bandwidth: \x1B[0m"<< bw <<" (MB/s)"<<std::endl;
}
delete [] kt1;
}
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
u8 *kt1 = new u8[size];
memset(kt1,'b',size);
- double total_sec = 0;
+ long double total_sec = 0;
+ long double trans_size = 0;
long double bw = 0;
if (has_match){
int pos = 0;
act_size += res - kt1;
}
auto end = std::chrono::steady_clock::now();
- double dt = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
- /*average time*/
- dt /= loops;
+ long double dt = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
total_sec += dt;
- /*average size*/
- act_size /= loops;
- double mb_size = (double) act_size / 1048576;
- bw += mb_size / dt;
+ /*calculate transferred size*/
+ trans_size += act_size * loops;
+ /*calculate bandwidth*/
+ bw += trans_size / total_sec;
+ /*convert to MB/s*/
+ bw += bw / 1048576;
+ /*calculte average time*/
+ total_sec /= loops;
}
total_sec /= M;
bw /= M;
+ /*covert average time to μs*/
+ long double ms = total_sec * 1000000;
std::cout << "\x1B[35m Case with match in random pos and size: " << real_size << " for " << loops<<" loops ("
- << M << " random possisions checked): \x1B[36m rshuftiExec elapsetime: \x1B[0m" << total_sec
- <<" (μs) \x1B[36m bandwidth: \x1B[0m" << bw <<" (MB/μs)"<<std::endl;
+ << M << " random possisions checked): \x1B[36m rshuftiExec elapsetime: \x1B[0m" << (ms/M)
+ <<" (μs) \x1B[36m bandwidth: \x1B[0m" << bw <<" (MB/s)"<<std::endl;
} else {
auto start = std::chrono::steady_clock::now();
for (int i = 0; i < loops; i++) {
rshuftiExec(lo, hi, kt1, kt1 + size);
}
auto end = std::chrono::steady_clock::now();
- total_sec += std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
- /*average time*/
- total_sec /=loops;
- double mb_size = (double) size / 1048576;
- bw = mb_size / total_sec;
- std::cout<<"\x1B[35m Case with no match in random pos and size: "<< real_size <<" for "<< loops <<" loops:"
- <<"\x1B[36m rshuftiExec elapsetime: \x1B[0m"<< total_sec <<" (μs) \x1B[36m bandwidth: \x1B[0m"<< bw <<" (MB/μs)"<<std::endl;
+ total_sec += std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
+ /*calculate transferred size*/
+ trans_size = size * loops ;
+ /*calculate bandwidth*/
+ bw = trans_size / total_sec;
+ /*convert to MB/s*/
+ bw /=1048576;
+ /*covert average time to μs*/
+ long double ms = total_sec * 1000000;
+ std::cout<<"\x1B[35m Case with no match in random pos and size: "<<real_size<<" for "<<loops<<" loops:"
+ <<"\x1B[36m rshuftiExec elapsetime: \x1B[0m"<<(ms/loops)<<" (μs) \x1B[36m bandwidth: \x1B[0m"<< bw <<" (MB/s)"<<std::endl;
}
delete [] kt1;
}
truffleBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
u8*kt1 = new u8[size];
memset(kt1,'b',size);
- double total_sec = 0;
+ long double total_sec = 0;
+ long double trans_size = 0;
long double bw = 0;
if (has_match){
int pos = 0;
act_size += res - kt1;
}
auto end = std::chrono::steady_clock::now();
- double dt = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
- /*average time*/
- dt /= loops;
+ long double dt = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
total_sec += dt;
- /*average size*/
- act_size /= loops;
- double mb_size = (double) act_size / 1048576;
- bw += mb_size / dt;
+ /*calculate transferred size*/
+ trans_size += act_size * loops;
+ /*calculate bandwidth*/
+ bw += trans_size / total_sec;
+ /*convert to MB/s*/
+ bw += bw / 1048576;
+ /*calculte average time*/
+ total_sec /= loops;
}
total_sec /= M;
bw /= M;
+ /*covert average time to μs*/
+ long double ms = total_sec * 1000000;
std::cout << "\x1B[35m Case with match in random pos and size: " << real_size << " for "<< loops <<" loops ("
- << M <<" random possisions checked): \x1B[36m truffleExec elapsetime: \x1B[0m" << total_sec
+ << M <<" random possisions checked): \x1B[36m truffleExec elapsetime: \x1B[0m" << (ms/M)
<< "(μs) \x1B[36m bandwidth: \x1B[0m"<< bw << "(MB/μs)" <<std::endl;
} else {
auto start = std::chrono::steady_clock::now();
truffleExec(lo, hi, kt1, kt1 + size);
}
auto end = std::chrono::steady_clock::now();
- total_sec += std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
- /*average time*/
- total_sec /= loops;
- double mb_size = (double) size / 1048576;
- bw = mb_size / total_sec;
- std::cout<<"\x1B[35m Case with no match in random pos and size: "<< real_size <<" for "<< loops <<" loops:"
- <<"\x1B[36m truffleExec elapsetime: \x1B[0m" << total_sec << " μs \x1B[36m bandwidth: \x1B[0m"<< bw <<" (MB/μs)"<<std::endl;
+ total_sec += std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
+ /*calculate transferred size*/
+ trans_size = size * loops ;
+ /*calculate bandwidth*/
+ bw = trans_size / total_sec;
+ /*convert to MB/s*/
+ bw /=1048576;
+ /*covert average time to μs*/
+ long double ms = total_sec * 1000000;
+ std::cout<<"\x1B[35m Case with no match in random pos and size: "<<real_size<<" for "<<loops<<" loops:"
+ <<"\x1B[36m truffleExec elapsetime: \x1B[0m"<<(ms/loops)<<" (μs) \x1B[36m bandwidth: \x1B[0m"<< bw <<" (MB/s)"<<std::endl;
}
delete [] kt1;
}
truffleBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
u8 *kt1 = new u8[size];
memset(kt1,'b',size);
- double total_sec = 0;
+ long double total_sec = 0;
+ long double trans_size = 0;
long double bw = 0;
if (has_match){
int pos = 0;
act_size += res - kt1;
}
auto end = std::chrono::steady_clock::now();
- double dt = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
- /*average time*/
- dt /= loops;
+ long double dt = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
total_sec += dt;
- /*average size*/
- act_size /= loops;
- double mb_size = (double) act_size / 1048576;
- bw += mb_size / dt;
+ /*calculate transferred size*/
+ trans_size += act_size * loops;
+ /*calculate bandwidth*/
+ bw += trans_size / total_sec;
+ /*convert to MB/s*/
+ bw += bw / 1048576;
+ /*calculte average time*/
+ total_sec /= loops;
}
total_sec /= M;
bw /= M;
+ /*covert average time to μs*/
+ long double ms = total_sec * 1000000;
std::cout<<"\x1B[35m Case with match in random pos and size: "<< real_size <<" for "<<loops<<" loops ("
<< M <<" random possisions checked):"<<"\x1B[36m rtruffleExec elapsetime: \x1B[0m"
- << total_sec <<" (μs) \x1B[36m bandwidth: \x1B[0m"<< bw <<"(ΜΒ/μs)"<<std::endl;
+ << (ms/M) <<" (μs) \x1B[36m bandwidth: \x1B[0m"<< bw <<"(ΜΒ/μs)"<<std::endl;
} else {
auto start = std::chrono::steady_clock::now();
for (int i = 0; i < loops; i++) {
rtruffleExec(lo, hi, kt1, kt1 + size);
}
auto end = std::chrono::steady_clock::now();
- total_sec += std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
- /*average time*/
- total_sec /= loops;
- double mb_size = (double) size / 1048576;
- bw = mb_size / total_sec;
- std::cout<<"\x1B[35m Case with no match in random pos and size: "<< real_size <<" for "<< loops <<" loops:"
- <<"\x1B[36m rtruffleExec elapsetime: \x1B[0m" << total_sec <<" (μs) \x1B[36m bandwidth: \x1B[0m"<< bw <<" (MB/μs)"<<std::endl;
+ total_sec += std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
+ /*calculate transferred size*/
+ trans_size = size * loops ;
+ /*calculate bandwidth*/
+ bw = trans_size / total_sec;
+ /*convert to MB/s*/
+ bw /=1048576;
+ /*covert average time to μs*/
+ long double ms = total_sec * 1000000;
+ std::cout<<"\x1B[35m Case with no match in random pos and size: "<<real_size<<" for "<<loops<<" loops:"
+ <<"\x1B[36m rtruffleExec elapsetime: \x1B[0m"<<(ms/loops)<<" (μs) \x1B[36m bandwidth: \x1B[0m"<< bw <<" (MB/s)"<<std::endl;
}
delete [] kt1;
}