mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-16 09:21:52 +03:00
bandwidth output fixes
This commit is contained in:
committed by
Konstantinos Margaritis
parent
b03428e584
commit
d39e132fdf
@@ -26,7 +26,8 @@ void truffle_benchmarks(int size, int loops, int M, bool has_match) {
|
||||
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;
|
||||
@@ -42,19 +43,23 @@ void truffle_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 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();
|
||||
@@ -62,13 +67,17 @@ void truffle_benchmarks(int size, int loops, int M, bool has_match) {
|
||||
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;
|
||||
}
|
||||
@@ -82,7 +91,8 @@ void rtruffle_benchmarks(int size, int loops, int M, bool has_match) {
|
||||
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;
|
||||
@@ -98,33 +108,41 @@ void rtruffle_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 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user