Commit cbb7597c authored by yiwenshao's avatar yiwenshao

able to test token size in SWP

parent f0b97665
......@@ -14,6 +14,7 @@ uint64_t cur_usec() {
}
using namespace std;
static
std::string
getpRandomName(int out_length = 10){
......
......@@ -17,7 +17,14 @@
#include "util/timer.hh"
#include "util/log.hh"
#include "util/onions.hh"
#include <sys/time.h>
static
uint64_t cur_usec() {
struct timeval tv;
gettimeofday(&tv, 0);
return ((uint64_t)tv.tv_sec) * 1000000 + tv.tv_usec;
}
using std::cout;
using std::cin;
using std::endl;
......@@ -32,6 +39,28 @@ static std::map<std::string, WrapperState*> clients;
Connect *globalConn;
static
std::string
getpRandomName(int out_length = 10){
static const char valids[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
char output[out_length + 1];
// std::function<bool()> wrap_srand =[](){srand(time(NULL)); return true;};
std::function<bool()> wrap_srand =[](){srand(cur_usec()); return true;};
std::function<void(bool)> do_nothing = [] (bool b) {return;};
static bool danger_will_robinson = wrap_srand();
do_nothing(danger_will_robinson);
for (int i = 0; i < out_length; ++i) {
output[i] = valids[rand() % strlen(valids)];
}
output[out_length] = 0;
return std::string(output);
}
/*for each field, convert the format to FieldMeta_Wrapper*/
......@@ -117,7 +146,9 @@ main(int argc,char**argv) {
return 0;
}
std::string input(length,'a');
std::string input = getpRandomName(length);//(length,'a');
auto res = tokenize(input);
Item* plain = getItemString(input);
......@@ -129,7 +160,8 @@ main(int argc,char**argv) {
}
std::cout<<"ENC_OPE_STR_IN_us: "<<t.lap()*1.0/num_of_tests<<std::endl;
std::cout<<"enclen: "<<enc->str_value.length()<<"##"<<"plainlen: "<<plain->str_value.length() <<std::endl;
std::cout<<"enclen: "<<enc->str_value.length()<<"##"<<"plainlen: "<<plain->str_value.length()
<<"tokennumber: "<<res->size()<<std::endl;
(void)enc;
return 0;
}
......
......@@ -1437,7 +1437,8 @@ token(const std::string &key, const std::string &word)
//currently, we split by whitespaces
// only consider words at least 3 chars in len
// discard not unique objects
static std::list<std::string> *
std::list<std::string> *
tokenize(const std::string &text)
{
std::list<std::string> tokens = split(text, " ,;:.");
......
......@@ -445,3 +445,6 @@ private:
};
std::list<std::string> *
tokenize(const std::string &text);
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