fix benchmarks outputs

This commit is contained in:
apostolos 2021-09-14 15:32:26 +03:00 committed by Konstantinos Margaritis
parent 53b9034546
commit ee8fa17351
5 changed files with 230 additions and 224 deletions

View File

@ -4,40 +4,25 @@
#include <string.h>
#include <time.h>
#include <functional>
#include <vector>
#define MAX_LOOPS 500000000
#define MAX_MATCHES 10
int main(){
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 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=11; i<12; i++) {
std::cout << labels[i];
for(int j=0; j<4; j++){
functions[j](sizes[i],f_loops[i],exp_len[i],false);
functions[j](sizes[i],t_loops[i],exp_len[i],true);
int sizes[] = { 16000, 32000, 64000, 120000, 1600000, 2000000, 2500000, 3500000, 150000000, 250000000, 350000000, 500000000 };
const char charset[] = "aAaAaAaAAAaaaaAAAAaaaaAAAAAAaaaAAaaa";
/*
for (size_t i = 0; i < std::size(sizes); i++) {
for(int j = 0; j < 4; j++) {
functions[j](sizes[i], MAX_LOOPS / sizes[i], MAX_MATCHES, false);
functions[j](sizes[i], MAX_LOOPS / sizes[i], MAX_MATCHES, true);
}
}
for(int i=0; i<12; i++){
if(i==0){
std::cout<<std::endl <<"\x1B[33m noodle Benchmarks(kbytes) \x1B[0m"<<std::endl;
}else if (i==4)
{
std::cout<<std::endl <<"\x1B[33m noodle Benchmarks(Mbytes) \x1B[0m"<<std::endl;
}else if (i==8)
{
std::cout<<std::endl <<"\x1B[33m noodle Benchmarks(Gbytes) \x1B[0m"<<std::endl;
}
*/
for(size_t i=0; i < std::size(sizes); i++){
//we imitate the noodle unit tests
for (int char_len = 1; char_len < 9; char_len++) {
char *str = new char[char_len];
for (int j=0; j<char_len; j++) {
@ -46,7 +31,7 @@ int main(){
str[char_len] = charset[key];
str[char_len + 1] = '\0';
}
noodle_benchmarks(sizes[i], nd_loops[i], str,char_len,0);
noodle_benchmarks(sizes[i], MAX_LOOPS / sizes[i], str,char_len, 0);
delete [] str;
}
}

View File

@ -1,3 +1,13 @@
/*define colour control characters*/
#define RST "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
void shufti_benchmarks(int size, int loops, int M, bool has_match);
void rshufti_benchmarks(int size, int loops, int M, bool has_match);
void truffle_benchmarks(int size, int loops, int M, bool has_match);

View File

@ -29,33 +29,40 @@ hwlmcb_rv_t hlmSimpleCallback(size_t to, u32 id,
return HWLM_CONTINUE_MATCHING;
}
void noodle_benchmarks(int size, int M, const char *lit_str, int lit_len, char nocase){
void noodle_benchmarks(int size, int loops, const char *lit_str, int lit_len, char nocase){
ctxt.clear();
u8 *data = new u8[size];
memset(data, 'a', size);
long double total_sec = 0;
long double trans_size = 0;
long double bw = 0;
double total_sec = 0.0;
u64a transferred_size = 0;
double avg_time = 0.0;
double max_bw = 0.0;
double bandwitdh = 0.0;
u32 id = 1000;
ue2::hwlmLiteral lit(std::string(lit_str, lit_len), nocase, id);
auto n = ue2::noodBuildTable(lit);
assert(n != nullptr);
struct hs_scratch scratch;
auto start = std::chrono::steady_clock::now();
for (int i = 0; i < M; i++){
for (int i = 0; i < loops; i++){
noodExec(n.get(), data, size, 0, hlmSimpleCallback, &scratch);
}
auto end = std::chrono::steady_clock::now();
total_sec += std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
total_sec += std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
/*calculate transferred size*/
trans_size = size * M;
/*convert to sec*/
bw = trans_size / total_sec;
transferred_size = size * loops;
/*calculate average time*/
avg_time = total_sec / loops;
/*convert microseconds to seconds*/
total_sec /= 1000000.0;
/*calculate maximum bandwidth*/
max_bw = transferred_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" << (ms/M) << " (μs) \x1B[36m bandwidth: \x1B[0m" << bw <<" (MB/s)" << std::endl;
max_bw /=1048576.0;
/*calculate average bandwidth*/
bandwitdh = max_bw / loops;
printf(KMAG "Case with %u matches in random pos with %u * %u iterations," KBLU " total elapsed time =" RST " %.3f s, "
KBLU "average time per call =" RST " %.3f μs," KBLU " bandwidth = " RST " %.3f MB/s," KBLU " average bandwidth =" RST " %.3f MB/s \n",
lit_len, size ,loops, total_sec, avg_time, max_bw, bandwitdh);
delete [] data;
}

View File

@ -7,142 +7,144 @@
#include <ctime>
#include <cstdlib>
/*
#define RST "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
*/
void shufti_benchmarks(int size, int loops, int M, bool has_match) {
size_t real_size = size;
m128 lo, hi;
ue2::CharReach chars;
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
u8 *kt1 = new u8[size];
memset(kt1,'b',size);
long double total_sec = 0;
long double trans_size = 0;
long double bw = 0;
if (has_match){
double total_sec = 0.0;
u64a transferred_size = 0;
double bandwitdh = 0.0;
double max_bw = 0.0;
double avg_time = 0.0;
if (has_match) {
int pos = 0;
for(int j=0; j<M; j++){
for(int j = 0; j < M; j++) {
kt1[pos] = 'b';
srand (time(NULL));
pos = rand() % size + 0;
kt1[pos] = 'a';
unsigned long act_size = 0;
auto start = std::chrono::steady_clock::now();
for (int i = 0; i < loops; i++) {
for(int i = 0; i < loops; i++) {
const u8 *res = shuftiExec(lo, hi, kt1, kt1 + size);
act_size += res - kt1;
}
auto end = std::chrono::steady_clock::now();
long double dt = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
double dt = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
total_sec += dt;
/*calculate transferred size*/
trans_size += act_size * loops;
/*convert microseconds to seconds*/
total_sec /= 1000000.0;
/*calculate bandwidth*/
bw += trans_size / total_sec;
bandwitdh += act_size / total_sec;
/*convert to MB/s*/
bw += bw / 1048576;
/*calculte average time*/
total_sec /= loops;
bandwitdh = bandwitdh / 1048576.0;
max_bw = std::max(bandwitdh ,max_bw);
/*calculate average time*/
avg_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 shuftiExec elapsetime: \x1B[0m" << (ms/M)
<<" (μs) \x1B[36m bandwidth: \x1B[0m" << bw <<" (MB/s)"<<std::endl;
avg_time /= M;
bandwitdh /= M;
/*convert average time to us*/
avg_time *= 1000000.0;
printf(KMAG "ShuftiExec: case with %u matches, %u * %u iterations," KBLU " total elapsed time =" RST " %.3f s, "
KBLU "average time per call =" RST " %.3f μs," KBLU " bandwidth = " RST " %.3f MB/s," KBLU " average bandwidth =" RST " %.3f MB/s \n",
M, size ,loops, total_sec, avg_time, max_bw, bandwitdh);
} 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::seconds>(end - start).count();
total_sec += std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
/*calculate transferred size*/
trans_size = size * loops ;
/*calculate bandwidth*/
bw = trans_size / total_sec;
transferred_size = size * loops;
/*calculate average time*/
avg_time = total_sec / loops;
/*convert microseconds to seconds*/
total_sec /= 1000000.0;
/*calculate maximum bandwidth*/
max_bw = transferred_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"<<(ms/loops)<<" (μs) \x1B[36m bandwidth: \x1B[0m"<< bw <<" (MB/s)"<<std::endl;
max_bw /=1048576.0;
/*calculate average bandwidth*/
bandwitdh = max_bw / loops;
printf(KMAG "ShuftiExec: case without matches, %u * %u iterations," KBLU " total elapsed time =" RST " %.3f s, "
KBLU "average time per call =" RST " %.3f μs ," KBLU " bandwidth = " RST " %.3f MB/s," KBLU " average bandwidth =" RST " %.3f MB/s \n",
size ,loops, total_sec, avg_time, max_bw, bandwitdh);
}
delete [] kt1;
}
void rshufti_benchmarks(int size, int loops, int M, bool has_match) {
size_t real_size = size;
m128 lo, hi;
ue2::CharReach chars;
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
u8 *kt1 = new u8[size];
memset(kt1,'b',size);
long double total_sec = 0;
long double trans_size = 0;
long double bw = 0;
if (has_match){
double total_sec = 0.0;
u64a transferred_size = 0;
double bandwitdh = 0.0;
double max_bw = 0.0;
double avg_time = 0.0;
if (has_match) {
int pos = 0;
for(int j=0; j<M; j++){
for(int j = 0; j < M; j++) {
kt1[pos] = 'b';
srand (time(NULL));
pos = rand() % size + 0;
kt1[pos] = 'a';
unsigned long act_size = 0;
auto start = std::chrono::steady_clock::now();
for (int i = 0; i < loops; i++) {
for(int i = 0; i < loops; i++) {
const u8 *res = rshuftiExec(lo, hi, kt1, kt1 + size);
act_size += res - kt1;
act_size += res - kt1;
}
auto end = std::chrono::steady_clock::now();
long double dt = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
double dt = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
total_sec += dt;
/*calculate transferred size*/
trans_size += act_size * loops;
/*convert microseconds to seconds*/
total_sec /= 1000000.0;
/*calculate bandwidth*/
bw += trans_size / total_sec;
bandwitdh += act_size / total_sec;
/*convert to MB/s*/
bw += bw / 1048576;
/*calculte average time*/
total_sec /= loops;
bandwitdh = bandwitdh / 1048576.0;
max_bw = std::max(bandwitdh ,max_bw);
/*calculate average time*/
avg_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" << (ms/M)
<<" (μs) \x1B[36m bandwidth: \x1B[0m" << bw <<" (MB/s)"<<std::endl;
avg_time /= M;
bandwitdh /= M;
/*convert average time to μs*/
avg_time *= 1000000.0;
printf(KMAG "rShuftiExec: case with %u matches, %u * %u iterations," KBLU " total elapsed time =" RST " %.3f s, "
KBLU "average time per call =" RST " %.3f μs," KBLU " bandwidth = " RST " %.3f MB/s," KBLU " average bandwidth =" RST " %.3f MB/s \n",
M, size ,loops, total_sec, avg_time, max_bw, bandwitdh);
} 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::seconds>(end - start).count();
total_sec += std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
/*calculate transferred size*/
trans_size = size * loops ;
/*calculate bandwidth*/
bw = trans_size / total_sec;
transferred_size = size * loops;
/*calculate average time*/
avg_time = total_sec / loops;
/*convert microseconds to seconds*/
total_sec /= 1000000.0;
/*calculate maximum bandwidth*/
max_bw = transferred_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;
max_bw /=1048576.0;
/*calculate average bandwidth*/
bandwitdh = max_bw / loops;
printf(KMAG "rShuftiExec: case without matches, %u * %u iterations," KBLU " total elapsed time =" RST " %.3f s, "
KBLU "average time per call =" RST " %.3f μs ," KBLU " bandwidth = " RST " %.3f MB/s," KBLU " average bandwidth =" RST " %.3f MB/s \n",
size ,loops, total_sec, avg_time, max_bw, bandwitdh);
}
delete [] kt1;
}

View File

@ -6,143 +6,145 @@
#include <cstring>
#include <ctime>
/*
#define RST "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
*/
void truffle_benchmarks(int size, int loops, int M, bool has_match) {
size_t real_size = size;
m128 lo, hi;
ue2::CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
u8*kt1 = new u8[size];
memset(kt1,'b',size);
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++){
kt1[pos] = 'b';
srand (time(NULL));
pos = rand() % size + 0;
kt1[pos] = 'a';
unsigned long act_size = 0;
auto start = std::chrono::steady_clock::now();
for (int i = 0; i < loops; i++) {
const u8 *res = truffleExec(lo, hi, kt1, kt1 + size);
act_size += res - kt1;
}
auto end = std::chrono::steady_clock::now();
long double dt = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
total_sec += 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" << (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++) {
truffleExec(lo, hi, kt1, kt1 + size);
}
auto end = std::chrono::steady_clock::now();
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;
}
void rtruffle_benchmarks(int size, int loops, int M, bool has_match) {
size_t real_size = size;
m128 lo, hi;
ue2::CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
u8 *kt1 = new u8[size];
memset(kt1,'b',size);
long double total_sec = 0;
long double trans_size = 0;
long double bw = 0;
if (has_match){
double total_sec = 0.0;
u64a transferred_size = 0;
double bandwitdh = 0.0;
double max_bw = 0.0;
double avg_time = 0.0;
if (has_match) {
int pos = 0;
for(int j=0; j<M; j++){
for(int j = 0; j < M; j++) {
kt1[pos] = 'b';
srand (time(NULL));
pos = rand() % size + 0;
kt1[pos] = 'a';
unsigned long act_size = 0;
auto start = std::chrono::steady_clock::now();
for (int i = 0; i < loops; i++) {
for(int i = 0; i < loops; i++) {
const u8 *res = truffleExec(lo, hi, kt1, kt1 + size);
act_size += res - kt1;
}
auto end = std::chrono::steady_clock::now();
double dt = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
total_sec += dt;
/*convert microseconds to seconds*/
total_sec /= 1000000.0;
/*calculate bandwidth*/
bandwitdh += act_size / total_sec;
/*convert to MB/s*/
bandwitdh = bandwitdh / 1048576.0;
max_bw = std::max(bandwitdh ,max_bw);
/*calculate average time*/
avg_time += total_sec / loops;
}
avg_time /= M;
bandwitdh /= M;
/*convert average time to us*/
avg_time *= 1000000.0;
printf(KMAG "TruffleExec: case with %u matches, %u * %u iterations," KBLU " total elapsed time =" RST " %.3f s, "
KBLU "average time per call =" RST " %.3f μs," KBLU " bandwidth = " RST " %.3f MB/s," KBLU " average bandwidth =" RST " %.3f MB/s \n",
M, size ,loops, total_sec, avg_time, max_bw, bandwitdh);
} else {
auto start = std::chrono::steady_clock::now();
for (int i = 0; i < loops; i++) {
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();
/*calculate transferred size*/
transferred_size = size * loops;
/*calculate average time*/
avg_time = total_sec / loops;
/*convert microseconds to seconds*/
total_sec /= 1000000.0;
/*calculate maximum bandwidth*/
max_bw = transferred_size / total_sec;
/*convert to MB/s*/
max_bw /=1048576.0;
/*calculate average bandwidth*/
bandwitdh = max_bw / loops;
printf(KMAG "TruffleExec case without matches, %u * %u iterations," KBLU " total elapsed time =" RST " %.3f s, "
KBLU "average time per call =" RST " %.3f μs ," KBLU " bandwidth = " RST " %.3f MB/s," KBLU " average bandwidth =" RST " %.3f MB/s \n",
size ,loops, total_sec, avg_time, max_bw, bandwitdh);
}
delete [] kt1;
}
void rtruffle_benchmarks(int size, int loops, int M, bool has_match) {
m128 lo, hi;
ue2::CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
u8 *kt1 = new u8[size];
memset(kt1,'b',size);
double total_sec = 0.0;
u64a transferred_size = 0;
double bandwitdh = 0.0;
double max_bw = 0.0;
double avg_time = 0.0;
if (has_match) {
int pos = 0;
for(int j = 0; j < M; j++) {
kt1[pos] = 'b';
srand (time(NULL));
pos = rand() % size + 0;
kt1[pos] = 'a';
unsigned long act_size = 0;
auto start = std::chrono::steady_clock::now();
for(int i = 0; i < loops; i++) {
const u8 *res = rtruffleExec(lo, hi, kt1, kt1 + size);
act_size += res - kt1;
}
auto end = std::chrono::steady_clock::now();
long double dt = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
double dt = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
total_sec += dt;
/*calculate transferred size*/
trans_size += act_size * loops;
/*convert microseconds to seconds*/
total_sec /= 1000000.0;
/*calculate bandwidth*/
bw += trans_size / total_sec;
bandwitdh += act_size / total_sec;
/*convert to MB/s*/
bw += bw / 1048576;
/*calculte average time*/
total_sec /= loops;
bandwitdh = bandwitdh / 1048576.0;
max_bw = std::max(bandwitdh ,max_bw);
/*calculate average time*/
avg_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"
<< (ms/M) <<" (μs) \x1B[36m bandwidth: \x1B[0m"<< bw <<"(ΜΒ/μs)"<<std::endl;
avg_time /= M;
bandwitdh /= M;
/*convert average time to us*/
avg_time *= 1000000.0;
printf(KMAG "rTruffleExec: case with %u matches, %u * %u iterations," KBLU " total elapsed time =" RST " %.3f s, "
KBLU "average time per call =" RST " %.3f μs," KBLU " bandwidth = " RST " %.3f MB/s," KBLU " average bandwidth =" RST " %.3f MB/s \n",
M, size ,loops, total_sec, avg_time, max_bw, bandwitdh);
} 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::seconds>(end - start).count();
total_sec += std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
/*calculate transferred size*/
trans_size = size * loops ;
/*calculate bandwidth*/
bw = trans_size / total_sec;
transferred_size = size * loops;
/*calculate average time*/
avg_time = total_sec / loops;
/*convert microseconds to seconds*/
total_sec /= 1000000.0;
/*calculate maximum bandwidth*/
max_bw = transferred_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;
max_bw /=1048576.0;
/*calculate average bandwidth*/
bandwitdh = max_bw / loops;
printf(KMAG "rTruffleExec case without matches, %u * %u iterations," KBLU " total elapsed time =" RST " %.3f s, "
KBLU "average time per call =" RST " %.3f μs ," KBLU " bandwidth = " RST " %.3f MB/s," KBLU " average bandwidth =" RST " %.3f MB/s \n",
size ,loops, total_sec, avg_time, max_bw, bandwitdh);
}
delete [] kt1;
}