Commit 6543f6f4 authored by yiwenshao's avatar yiwenshao

test_layers

parent d3bc7806
...@@ -90,16 +90,39 @@ Create_field* getUnsignedIntField(){ ...@@ -90,16 +90,39 @@ Create_field* getUnsignedIntField(){
*/ */
int int
main() { main(int argc,char** argv) {
init(); init();
create_embedded_thd(0); create_embedded_thd(0);
std::string key = "key"; std::string key = "key";
Create_field *cf = NULL; Create_field *cf = NULL;
ASHE* as = new ASHE(*cf, key); ASHE* as = new ASHE(*cf, key);
Item* plain = getItemInt("123"); int num_of_tests = 10000;
Item* enc = as->encrypt(*plain,0u);
Item* dec = as->decrypt(*enc,0u); if(argc==2){
num_of_tests = std::stoi(std::string(argv[1]));
}else{
std::cout<<"num_of_tests:length"<<std::endl;
}
Item * plain = getItemInt("123456789");
std::cout<<"num_of_tests: "<<num_of_tests<<std::endl;
Item* enc = NULL;
Item* dec = NULL;
timer t;
for(int i=0;i<num_of_tests;i++) {
enc = as->encrypt(*plain,0u);
}
std::cout<<"ENC_ASHE_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
for(int i=0;i<num_of_tests;i++) {
dec = as->decrypt(*enc,0u);
}
std::cout<<"DEC_ASHE_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
(void)dec; (void)dec;
return 0; return 0;
......
...@@ -101,7 +101,7 @@ Create_field* getUnsignedIntField(){ ...@@ -101,7 +101,7 @@ Create_field* getUnsignedIntField(){
int int
main() { main(int argc,char**argv) {
init(); init();
create_embedded_thd(0); create_embedded_thd(0);
std::string key = "key"; std::string key = "key";
...@@ -109,9 +109,28 @@ main() { ...@@ -109,9 +109,28 @@ main() {
DET_int* ds = new DET_int(*cf, key); DET_int* ds = new DET_int(*cf, key);
Item* plain = getItemInt("123"); int num_of_tests = 10000;
Item* enc = ds->encrypt(*plain,0u); if(argc==2){
Item* dec = ds->decrypt(*enc,0u); num_of_tests = std::stoi(std::string(argv[1]));
}else{
std::cout<<"num_of_tests:length"<<std::endl;
}
Item * plain = getItemInt("123456789");
std::cout<<"num_of_tests: "<<num_of_tests<<std::endl;
Item * enc = NULL;
Item * dec = NULL;
timer t;
for(int i=0;i<num_of_tests;i++) {
enc = ds->encrypt(*plain,0u);
}
std::cout<<"DEC_DET_int_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
for(int i=0;i<num_of_tests;i++) {
dec = ds->decrypt(*enc,0u);
}
std::cout<<"ENC_DET_int_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
(void)dec; (void)dec;
return 0; return 0;
......
...@@ -99,16 +99,41 @@ Create_field* getUnsignedIntField(){ ...@@ -99,16 +99,41 @@ Create_field* getUnsignedIntField(){
*/ */
int int
main() { main(int argc,char**argv) {
init(); init();
create_embedded_thd(0); create_embedded_thd(0);
std::string key = "key"; std::string key = "key";
Create_field *cf = NULL; Create_field *cf = NULL;
DET_str* ds = new DET_str(*cf, key); DET_str* ds = new DET_str(*cf, key);
Item* plain = getItemString("helloworld"); int num_of_tests = 10000;
Item* enc = ds->encrypt(*plain,0u); int length = 16;
Item* dec = ds->decrypt(*enc,0u);
if(argc==3){
num_of_tests = std::stoi(std::string(argv[1]));
length = std::stoi(std::string(argv[2]));
}else{
std::cout<<"num_of_tests:length"<<std::endl;
}
std::string input(length,'a');
Item* plain = getItemString(input);
Item* enc = NULL;
Item* dec = NULL;
std::cout<<"length: "<<length<<" ## "<<"num_of_tests: "<<num_of_tests<<std::endl;
timer t;
for(int i=0;i<num_of_tests;i++) {
enc = ds->encrypt(*plain,0u);
}
std::cout<<"ENC_DET_STR_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
for(int i=0;i<num_of_tests;i++) {
dec = ds->decrypt(*enc,0u);
}
std::cout<<"DEC_DET_STR_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
(void)dec; (void)dec;
return 0; return 0;
......
...@@ -58,22 +58,13 @@ static void init(){ ...@@ -58,22 +58,13 @@ static void init(){
globalConn = new Connect(ci.server, ci.user, ci.passwd, ci.port); globalConn = new Connect(ci.server, ci.user, ci.passwd, ci.port);
} }
static
Item *
getItemString(std::string input) {
return MySQLFieldTypeToItem(MYSQL_TYPE_STRING, input);
}
/*
static static
Item * Item *
getItemInt(std::string input) { getItemInt(std::string input) {
return new (current_thd->mem_root) return new (current_thd->mem_root)
Item_int(static_cast<ulonglong>(valFromStr(input))); Item_int(static_cast<ulonglong>(valFromStr(input)));
} }
/*
static static
Item * Item *
getItemString(std::string input) { getItemString(std::string input) {
...@@ -99,18 +90,40 @@ Create_field* getUnsignedIntField(){ ...@@ -99,18 +90,40 @@ Create_field* getUnsignedIntField(){
*/ */
int int
main() { main(int argc,char**argv) {
init(); init();
create_embedded_thd(0); create_embedded_thd(0);
std::string key = "key"; std::string key = "key";
Create_field *cf = NULL; Create_field *cf = NULL;
HOM* hm = new HOM(*cf, key); HOM* hm = new HOM(*cf, key);
Item* plain = getItemString("helloworld"); int num_of_tests = 10000;
Item* enc = hm->encrypt(*plain,0u); if(argc==2){
Item* dec = hm->decrypt(*enc,0u); num_of_tests = std::stoi(std::string(argv[1]));
(void)dec; }else{
std::cout<<"num_of_tests"<<std::endl;
}
Item* plain = getItemInt("123456789");
Item *enc = NULL;
Item *dec = NULL;
std::cout<<"num_of_tests: "<<num_of_tests <<std::endl;
timer t;
for(int i=0;i<num_of_tests;i++) {
enc = hm->encrypt(*plain,0u);
}
std::cout<<"HOM_ENC_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
for(int i=0;i<num_of_tests;i++) {
dec = hm->decrypt(*enc,0u);
}
std::cout<<"HOM_DEC_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
(void)dec;
return 0; return 0;
} }
......
...@@ -102,17 +102,37 @@ Create_field* getUnsignedIntField(){ ...@@ -102,17 +102,37 @@ Create_field* getUnsignedIntField(){
int int
main() { main(int argc,char** argv) {
init(); init();
create_embedded_thd(0); create_embedded_thd(0);
std::string key = "key"; std::string key = "key";
Create_field *cf = getUnsignedIntField(); Create_field *cf = getUnsignedIntField();
OPE_int* op = new OPE_int(*cf, key); OPE_int* op = new OPE_int(*cf, key);
Item* plain = getItemInt("123"); //getItemString("helloworld"); int num_of_tests = 10000;
if(argc==2){
num_of_tests = std::stoi(std::string(argv[1]));
}else{
std::cout<<"num_of_tests:length"<<std::endl;
}
Item* enc = op->encrypt(*plain,0u); std::cout<<"num_of_tests: "<<num_of_tests<<std::endl;
Item* dec = op->decrypt(*enc,0u); Item* plain = getItemInt("123456789"); //getItemString("helloworld");
Item* enc = NULL;
Item* dec = NULL;
timer t;
for(int i=0;i<num_of_tests;i++) {
enc = op->encrypt(*plain,0u);
}
std::cout<<"ENC_OPE_int_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
for(int i=0;i<num_of_tests;i++) {
dec = op->decrypt(*enc,0u);
}
std::cout<<"DEC_OPE_int_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
(void)dec; (void)dec;
return 0; return 0;
......
...@@ -98,19 +98,36 @@ Create_field* getUnsignedIntField(){ ...@@ -98,19 +98,36 @@ Create_field* getUnsignedIntField(){
*/ */
int int
main() { main(int argc,char** argv) {
init(); init();
create_embedded_thd(0); create_embedded_thd(0);
std::string key = "key"; std::string key = "key";
Create_field *cf = NULL; Create_field *cf = NULL;
OPE_str* op = new OPE_str(*cf, key); OPE_str* op = new OPE_str(*cf, key);
Item* plain = getItemString("helloworld"); int num_of_tests = 10000;
Item* enc = op->encrypt(*plain,0u); int length = 16;
// Item* dec = op->decrypt(*enc,0u);
(void)enc;
if(argc==3){
num_of_tests = std::stoi(std::string(argv[1]));
length = std::stoi(std::string(argv[2]));
}else{
std::cout<<"num_of_tests:length"<<std::endl;
}
std::string input(length,'a');
Item* plain = getItemString(input);
std::cout<<"length: "<<length<<" ## "<<"num_of_tests: "<<num_of_tests<<std::endl;
timer t;
Item* enc = NULL;
for(int i=0;i<num_of_tests;i++) {
enc = op->encrypt(*plain,0u);
}
std::cout<<"ENC_OPE_STR_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
(void)enc;
return 0; return 0;
} }
......
...@@ -103,16 +103,39 @@ Create_field* getUnsignedIntField(){ ...@@ -103,16 +103,39 @@ Create_field* getUnsignedIntField(){
int int
main() { main(int argc, char**argv) {
init(); init();
create_embedded_thd(0); create_embedded_thd(0);
std::string key = "key"; std::string key = "key";
Create_field *cf = getUnsignedIntField(); Create_field *cf = getUnsignedIntField();
RND_int* ri = new RND_int(*cf, key); RND_int* ri = new RND_int(*cf, key);
Item* plain = getItemInt("123"); int num_of_tests = 10000;
Item* enc = ri->encrypt(*plain,0u); if(argc==2){
Item* dec = ri->decrypt(*enc,0u); num_of_tests = std::stoi(std::string(argv[1]));
}else{
std::cout<<"num_of_tests:length"<<std::endl;
}
Item * plain = getItemInt("123456789");
std::cout<<"num_of_tests: "<<num_of_tests<<std::endl;
Item * enc = NULL;
Item * dec = NULL;
timer t;
for(int i=0;i<num_of_tests;i++){
enc = ri->encrypt(*plain,0u);
}
std::cout<<"ENC_RND_int_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
for(int i=0;i<num_of_tests;i++){
dec = ri->decrypt(*enc,0u);
}
std::cout<<"DEC_RND_int_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
(void)dec; (void)dec;
return 0; return 0;
......
...@@ -99,18 +99,41 @@ Create_field* getUnsignedIntField(){ ...@@ -99,18 +99,41 @@ Create_field* getUnsignedIntField(){
*/ */
int int
main() { main(int argc,char**argv) {
init(); init();
create_embedded_thd(0); create_embedded_thd(0);
std::string key = "key"; std::string key = "key";
Create_field *cf = NULL; Create_field *cf = NULL;
RND_str* rs = new RND_str(*cf, key); RND_str* rs = new RND_str(*cf, key);
Item* plain = getItemString("helloworld"); int num_of_tests = 10000;
Item* enc = rs->encrypt(*plain,0u); int length = 16;
Item* dec = rs->decrypt(*enc,0u);
(void)dec; if(argc==3){
num_of_tests = std::stoi(std::string(argv[1]));
length = std::stoi(std::string(argv[2]));
}else{
std::cout<<"num_of_tests:length"<<std::endl;
}
std::string input(length,'a');
Item* plain = getItemString(input);
Item* enc = NULL;
Item* dec = NULL;
std::cout<<"length: "<<length<<" ## "<<"num_of_tests: "<<num_of_tests<<std::endl;
timer t;
for(int i=0;i<num_of_tests;i++){
enc = rs->encrypt(*plain,0u);
}
std::cout<<"ENC_RND_STR_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
for(int i=0;i<num_of_tests;i++){
dec = rs->decrypt(*enc,0u);
}
std::cout<<"DEC_RND_STR_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
(void)dec;
(void)enc;
return 0; return 0;
} }
......
...@@ -99,19 +99,35 @@ Create_field* getUnsignedIntField(){ ...@@ -99,19 +99,35 @@ Create_field* getUnsignedIntField(){
*/ */
int int
main() { main(int argc,char**argv) {
init(); init();
create_embedded_thd(0); create_embedded_thd(0);
std::string key = "key"; std::string key = "key";
Create_field *cf = NULL; Create_field *cf = NULL;
Search* sw = new Search(*cf, key); Search* sw = new Search(*cf, key);
Item* plain = getItemString("helloworld"); int num_of_tests = 10000;
int length = 16;
Item* enc = sw->encrypt(*plain,0u); if(argc==3){
// Item* dec = ds->decrypt(*enc,0u); num_of_tests = std::stoi(std::string(argv[1]));
(void)enc; length = std::stoi(std::string(argv[2]));
}else{
std::cout<<"num_of_tests:length"<<std::endl;
}
std::string input(length,'a');
Item* plain = getItemString(input);
std::cout<<"length: "<<length<<" ## "<<"num_of_tests: "<<num_of_tests<<std::endl;
timer t;
Item* enc = NULL;
for(int i=0;i<num_of_tests;i++) {
enc = sw->encrypt(*plain,0u);
}
std::cout<<"ENC_OPE_STR_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
(void)enc;
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment