mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
code size reduction by using function arrays and add bandwidth to output
This commit is contained in:
parent
904a94fbe5
commit
1009391d9f
@ -3,117 +3,50 @@
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <functional>
|
||||
int main(){
|
||||
int sizes[]= { 10000, 16000, 32000, 64000, 120000, 1232896, 1600000, 2000000, 2500000, 3500000, 100000000, 150000000, 250000000, 350000000, 500000000};
|
||||
int iters[]= { 10000, 16000, 32000, 64000, 120000, 5000, 3000, 3000, 3000, 2000, 25, 25, 3, 3, 2};
|
||||
int exp_len[]= { 10000, 16000, 32000, 64000, 120000, 600000, 1000000, 1000000, 1500000, 3500000, 1000000, 10000000, 20000000, 30000000, 40000000};
|
||||
int sizes[]= { 16000, 32000, 64000, 120000, 1600000, 2000000, 2500000, 3500000, 150000000, 250000000, 350000000, 500000000};
|
||||
int iters[]= { 16000, 32000, 64000, 120000, 3000, 3000, 3000, 2000, 25, 3, 3, 2};
|
||||
int exp_len[]= { 16000, 32000, 64000, 120000, 1000000, 1000000, 1500000, 3500000, 10000000, 20000000, 30000000, 40000000};
|
||||
const char charset[] = "aAaAaAaAAAaaaaAAAAaaaaAAAAAAaaaAAaaa";
|
||||
std::cout<<std::endl <<"\x1B[33m shuftiExec Benchmarks(kbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
shufti_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
shufti_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
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::function<void(int,int,int,bool)> functions[] = { shufti_benchmarks, rshufti_benchmarks, truffle_benchmarks, rtruffle_benchmarks };
|
||||
|
||||
for (int i=0; i<12; i++) {
|
||||
std::cout << labels[i];
|
||||
for(int j=0; j<4; j++){
|
||||
functions[j](sizes[i],iters[i],exp_len[i],false);
|
||||
functions[j](sizes[i],iters[i],exp_len[i],true);
|
||||
}
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m rshuftiExec Benchmarks(kbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
rshufti_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
rshufti_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m truffleExec Benchmarks(kbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
truffle_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
truffle_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m rtruffleExec Benchmarks(kbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
rtruffle_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
rtruffle_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m shuftiExec Benchmarks(Mbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 5; i < 10; i++) {
|
||||
shufti_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
shufti_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m rshuftiExec Benchmarks(Mbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 5; i < 10; i++) {
|
||||
rshufti_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
rshufti_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m truffleExec Benchmarks(Mbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 5; i < 10; i++) {
|
||||
truffle_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
truffle_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m rtruffleExec Benchmarks(Mbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 5; i < 10; i++) {
|
||||
rtruffle_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
rtruffle_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m shuftiExec Benchmarks(Gbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 10; i < 15; i++) {
|
||||
shufti_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
shufti_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
// run time 2.5 min
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m rshuftiExec Benchmarks(Gbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 10; i < 15; i++) {
|
||||
rshufti_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
rshufti_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m truffleExec Benchmarks(Gbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 10; i < 15; i++) {
|
||||
truffle_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
truffle_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m rtruffleExec Benchmarks(Gbytes) \x1B[0m"<<std::endl;
|
||||
for (int i = 10; i < 15; i++) {
|
||||
rtruffle_benchmarks(sizes[i],iters[i],exp_len[i],false);
|
||||
rtruffle_benchmarks(sizes[i],iters[i],exp_len[i],true);
|
||||
}
|
||||
/*noodle_benchmarks(120000, 32000, "aaaA", 4, 1); ---> kill
|
||||
noodle_benchmarks(2500000, 5000, "AaAAaaaA", 8, 1); ---> kill
|
||||
γενικά όταν βάζω ένα string μεγέθους > 4 για nocase = 1 κάνει kill.
|
||||
*/
|
||||
std::cout<<std::endl <<"\x1B[33m noodle Benchmarks(kbytes) \x1B[0m"<<std::endl;
|
||||
for (int char_len = 1; char_len < 9; char_len++) {
|
||||
char *str = new char[char_len];
|
||||
for (int j=0; j<char_len; j++) {
|
||||
srand (time(NULL));
|
||||
int key = rand() % + 36 ;
|
||||
str[char_len] = charset[key];
|
||||
str[char_len + 1] = '\0';
|
||||
|
||||
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 (int i=0; i<5; i++){
|
||||
for (int char_len = 1; char_len < 9; char_len++) {
|
||||
char *str = new char[char_len];
|
||||
for (int j=0; j<char_len; j++) {
|
||||
srand (time(NULL));
|
||||
int key = rand() % + 36 ;
|
||||
str[char_len] = charset[key];
|
||||
str[char_len + 1] = '\0';
|
||||
}
|
||||
noodle_benchmarks(sizes[i], iters[i], str,char_len,0);
|
||||
delete [] str;
|
||||
}
|
||||
delete [] str;
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m noodle Benchmarks(Mbytes) \x1B[0m"<<std::endl;
|
||||
for (int char_len = 1; char_len < 9; char_len++) {
|
||||
char *str = new char[char_len];
|
||||
for (int j=0; j<char_len; j++) {
|
||||
srand (time(NULL));
|
||||
int key = rand() % + 36 ;
|
||||
str[char_len] = charset[key];
|
||||
str[char_len + 1] = '\0';
|
||||
}
|
||||
for (int i=5; i<10; i++){
|
||||
noodle_benchmarks(sizes[i], iters[i], str,char_len,0);
|
||||
}
|
||||
delete [] str;
|
||||
}
|
||||
std::cout<<std::endl <<"\x1B[33m noodle Benchmarks(Gbytes) \x1B[0m"<<std::endl;
|
||||
for (int char_len = 1; char_len < 9; char_len++) {
|
||||
char *str = new char[char_len];
|
||||
for (int j=0; j<char_len; j++) {
|
||||
srand (time(NULL));
|
||||
int key = rand() % + 36 ;
|
||||
str[char_len] = charset[key];
|
||||
str[char_len + 1] = '\0';
|
||||
}
|
||||
for (int i=10; i<15; i++){
|
||||
noodle_benchmarks(sizes[i], iters[i], str,char_len,0);
|
||||
}
|
||||
delete [] str;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -47,5 +47,6 @@ void noodle_benchmarks(int size, int M, const char *lit_str, int lit_len, char n
|
||||
total_sec += noodExec_elapsed_seconds.count();
|
||||
}
|
||||
total_sec /= M;
|
||||
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<<std::endl;
|
||||
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<<" bandwidth"<<(size/total_sec)<<std::endl;
|
||||
delete [] data;
|
||||
}
|
@ -36,7 +36,7 @@ void shufti_benchmarks(int size, int loops, int M, bool has_match) {
|
||||
total_sec += shuftiExec_elapsed_seconds.count();
|
||||
}
|
||||
total_sec /= M;
|
||||
std::cout<<"\x1B[35m Case with match in random pos and size: "<<size<<" for "<<loops<<" loops ("<< M <<" random possisions checked):"<<"\x1B[36m shuftiExec elapsetime: \x1B[0m"<<total_sec<<std::endl;
|
||||
std::cout<<"\x1B[35m Case with match in random pos and size: "<<size<<" for "<<loops<<" loops ("<< M <<" random possisions checked):"<<"\x1B[36m shuftiExec elapsetime: \x1B[0m"<<total_sec<<" bandwidth"<<(size/total_sec)<<std::endl;
|
||||
} else {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
for (int i = 0; i < loops; i++) {
|
||||
@ -45,7 +45,7 @@ void shufti_benchmarks(int size, int loops, int M, bool has_match) {
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
std::chrono::duration<double> shuftiExec_elapsed_seconds = end-start;
|
||||
total_sec += shuftiExec_elapsed_seconds.count();
|
||||
std::cout<<"\x1B[35m Case with no match in random pos and size: "<<size<<" for "<<loops<<" loops:"<<"\x1B[36m shuftiExec elapsetime: \x1B[0m"<<total_sec<<std::endl;
|
||||
std::cout<<"\x1B[35m Case with no match in random pos and size: "<<size<<" for "<<loops<<" loops:"<<"\x1B[36m shuftiExec elapsetime: \x1B[0m"<<total_sec<<" bandwidth"<<(size/total_sec)<<std::endl;
|
||||
}
|
||||
delete [] kt1;
|
||||
}
|
||||
@ -71,7 +71,7 @@ void rshufti_benchmarks(int size, int loops, int M, bool has_match) {
|
||||
total_sec += shuftiExec_elapsed_seconds.count();
|
||||
}
|
||||
total_sec /= M;
|
||||
std::cout<<"\x1B[35m Case with match in random pos and size: "<<size<<" for "<<loops<<" loops ("<< M <<" random possisions checked):"<<"\x1B[36m rshuftiExec elapsetime: \x1B[0m"<<total_sec<<std::endl;
|
||||
std::cout<<"\x1B[35m Case with match in random pos and size: "<<size<<" for "<<loops<<" loops ("<< M <<" random possisions checked):"<<"\x1B[36m rshuftiExec elapsetime: \x1B[0m"<<total_sec<<" bandwidth"<<(size/total_sec)<<std::endl;
|
||||
} else {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
for (int i = 0; i < loops; i++) {
|
||||
@ -80,7 +80,7 @@ void rshufti_benchmarks(int size, int loops, int M, bool has_match) {
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
std::chrono::duration<double> shuftiExec_elapsed_seconds = end-start;
|
||||
total_sec += shuftiExec_elapsed_seconds.count();
|
||||
std::cout<<"\x1B[35m Case with no match in random pos and size: "<<size<<" for "<<loops<<" loops:"<<"\x1B[36m rshuftiExec elapsetime: \x1B[0m"<<total_sec<<std::endl;
|
||||
std::cout<<"\x1B[35m Case with no match in random pos and size: "<<size<<" for "<<loops<<" loops:"<<"\x1B[36m rshuftiExec elapsetime: \x1B[0m"<<total_sec<<" bandwidth"<<(size/total_sec)<<std::endl;
|
||||
}
|
||||
delete [] kt1;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ void truffle_benchmarks(int size, int loops, int M, bool has_match) {
|
||||
total_sec += shuftiExec_elapsed_seconds.count();
|
||||
}
|
||||
total_sec /= M;
|
||||
std::cout<<"\x1B[35m Case with match in random pos and size: "<<size<<" for "<<loops<<" loops ("<< M <<" random possisions checked):"<<"\x1B[36m truffleExec elapsetime: \x1B[0m"<<total_sec<<std::endl;
|
||||
std::cout<<"\x1B[35m Case with match in random pos and size: "<<size<<" for "<<loops<<" loops ("<< M <<" random possisions checked):"<<"\x1B[36m truffleExec elapsetime: \x1B[0m"<<total_sec<<" bandwidth"<<(size/total_sec)<<std::endl;
|
||||
} else {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
for (int i = 0; i < loops; i++) {
|
||||
@ -45,7 +45,7 @@ void truffle_benchmarks(int size, int loops, int M, bool has_match) {
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
std::chrono::duration<double> shuftiExec_elapsed_seconds = end-start;
|
||||
total_sec += shuftiExec_elapsed_seconds.count();
|
||||
std::cout<<"\x1B[35m Case with no match in random pos and size: "<<size<<" for "<<loops<<" loops:"<<"\x1B[36m truffleExec elapsetime: \x1B[0m"<<total_sec<<std::endl;
|
||||
std::cout<<"\x1B[35m Case with no match in random pos and size: "<<size<<" for "<<loops<<" loops:"<<"\x1B[36m truffleExec elapsetime: \x1B[0m"<<total_sec<<" bandwidth"<<(size/total_sec)<<std::endl;
|
||||
}
|
||||
delete [] kt1;
|
||||
}
|
||||
@ -72,7 +72,7 @@ void rtruffle_benchmarks(int size, int loops, int M, bool has_match) {
|
||||
total_sec += shuftiExec_elapsed_seconds.count();
|
||||
}
|
||||
total_sec /= M;
|
||||
std::cout<<"\x1B[35m Case with match in random pos and size: "<<size<<" for "<<loops<<" loops ("<< M <<" random possisions checked):"<<"\x1B[36m rtruffleExec elapsetime: \x1B[0m"<<total_sec<<std::endl;
|
||||
std::cout<<"\x1B[35m Case with match in random pos and size: "<<size<<" for "<<loops<<" loops ("<< M <<" random possisions checked):"<<"\x1B[36m rtruffleExec elapsetime: \x1B[0m"<<total_sec<<" bandwidth"<<(size/total_sec)<<std::endl;
|
||||
} else {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
for (int i = 0; i < loops; i++) {
|
||||
@ -81,7 +81,7 @@ void rtruffle_benchmarks(int size, int loops, int M, bool has_match) {
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
std::chrono::duration<double> shuftiExec_elapsed_seconds = end-start;
|
||||
total_sec += shuftiExec_elapsed_seconds.count();
|
||||
std::cout<<"\x1B[35m Case with no match in random pos and size: "<<size<<" for "<<loops<<" loops:"<<"\x1B[36m rtruffleExec elapsetime: \x1B[0m"<<total_sec<<std::endl;
|
||||
std::cout<<"\x1B[35m Case with no match in random pos and size: "<<size<<" for "<<loops<<" loops:"<<"\x1B[36m rtruffleExec elapsetime: \x1B[0m"<<total_sec<<" bandwidth"<<(size/total_sec)<<std::endl;
|
||||
}
|
||||
delete [] kt1;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user