bandwidth output fixes

This commit is contained in:
apostolos
2021-09-13 20:25:46 +03:00
committed by Konstantinos Margaritis
parent b03428e584
commit d39e132fdf
4 changed files with 131 additions and 88 deletions

View File

@@ -27,8 +27,9 @@ void shufti_benchmarks(int size, int loops, int M, bool has_match) {
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++){
@@ -43,34 +44,41 @@ void shufti_benchmarks(int size, int loops, int M, bool has_match) {
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;
}
@@ -83,7 +91,8 @@ void rshufti_benchmarks(int size, int loops, int M, bool has_match) {
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;
@@ -99,33 +108,41 @@ void rshufti_benchmarks(int size, int loops, int M, bool has_match) {
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;
}