Hi All,
I have checked the banchmark of some regex lib. re2 has the best But when I have checked with one pattern and one message,its taking lotes of time to process and getting the match portion.its taking 225 matching per sec .Below is my code in cpp also the pattern and msg is present.I am looping for 50 K time the same pattern and mesg.
const char* msg = "<14>Mar 2 11:34:38 89.237.143.23 MSWinEventLog 1 Security 6500 Fri Mar 02 11:34:37 2012 4816\tMicrosoft-Windows-Security-Auditing\tN/A\tN/A\tSuccess Audit\
txyz.abc.com\tUser Logoff\tRPC detected an integrity violation while decrypting an incoming message. Peer Name: %1 Protocol Sequence: %2 Security Error: %3";
std::string pattern = "MSWinEventLog\\s*(?:(?:(?:\\s+)))\\s*(?:\\s*(?:(?:(?:\\d\\s+)))\\s*)?\\s*(?:(?P<event_log__string>(?:\\S+)))\\s*\\s*(?:(?:(?:.*?)))\\s*\\s*(?:(?:(?:\\s+)))\\s*\\s*(?:(?P<event_id__0>(?:4816)))\\s*\\s*(?:(?:(?:[\t]+)))\\s*\\s*(?:(?P<event_source__all>(?:.*?)))\\s*\\s*(?:(?:(?:[\t]+)))\\s*\\s*(?:(?:(?:.*?)))\\s*\\s*(?:(?:(?:[\t]+)))\\s*\\s*(?:(?:(?:.*?)))\\s*\\s*(?:(?:(?:[\t]+)))\\s*\\s*(?:(?:(?:.*?)))\\s*\\s*(?:(?:(?:[\t]+)))\\s*\\s*(?:(?:(?:.*?)))\\s*\\s*(?:(?:(?:[\t]+)))\\s*\\s*(?:(?P<event_category__all>(?:.*?)))\\s*\\s*(?:(?:(?:[\t]+)))\\s*RPC\\s*(?:(?P<action__0>(?:detected)))\\s*\\s*(?:(?:(?:.*?)))\\s*\\s*(?:(?P<object__0>(?:integrity violation)))\\s*\\s*(?:(?:(?:while decrypting an incoming message.*?)))\\s*Peer\\ Name\\:\\s*(?:(?P<peer_name__all>(?:.*?)))\\s*Protocol\\s*(?:(?:(?:.*?)))\\s*Security\\ Error\\:\\s*(?:(?P<error_code__0>(?:\\S+)))\\s*";
g_test_timer_start ();
for(count ; count < loop_limit ; count++){
string str(msg);
re2::StringPiece input(str);
re2::RE2 re(pattern);
int groupSize = re.NumberOfCapturingGroups();
vector<re2::RE2::Arg> argv(groupSize);
vector<re2::RE2::Arg*> args(groupSize);
vector<re2::StringPiece> ws(groupSize);
for (int i = 0; i < groupSize; ++i) {
args[i] = &argv[i];
argv[i] = &ws[i];
}
re2::RE2::PartialMatchN(input, re, &(args[0]), groupSize);
string s;
//for (int i = 0; i < groupSize; ++i){
//std::cout << ws[i] << std::endl << "\n" ;
// }
const map<int,string>& name= re.CapturingGroupNames();
map<int,string> ret = name;
map<int,string> :: iterator iter;
iter = ret.begin();
re2::StringPiece match[groupSize];
int length = str.length();
std::string event;
struct timeval start, end;
}
double timeForLoopLimit = g_test_timer_elapsed ();
std::cout << "\nsimpleCEFParser; Ran simpleCEFParser for " <<loop_limit << "times" << "; time_taken = " << timeForLoopLimit << "seconds, " << " speed =" << loop_limit/timeForLoopLimit;