From 0ef61c7e0b31f78944623af42a013592ab2d6248 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Mon, 19 Jul 2021 02:38:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=80=A7=E8=83=BD=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B=EF=BC=9A=20=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8B=E3=80=81=E9=AB=98=E5=91=BD=E4=B8=AD?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=E7=9A=84=E6=89=AB=E6=8F=8F=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/perf_test_maatframe.cpp | 50 +++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/test/perf_test_maatframe.cpp b/test/perf_test_maatframe.cpp index ab6e10f..d51a4c0 100644 --- a/test/perf_test_maatframe.cpp +++ b/test/perf_test_maatframe.cpp @@ -301,10 +301,10 @@ Maat_feather_t MaatCMDPerfTest::_shared_feather; void* MaatCMDPerfTest::logger; //Following tests must be coded/tested at last, for they stalled the maat update thread and interrupt other tests. -TEST_F(MaatCMDPerfTest, SetExpr200K) +TEST_F(MaatCMDPerfTest, SetExpr50K) { // const int CMD_EXPR_NUM=2*100*1000; - const int CMD_EXPR_NUM=2*100; + const int CMD_EXPR_NUM=50*1000; const int CMD_IP_NUM=3*1000; const char* expr_table_name="HTTP_URL"; const char* ip_table_name="IP_CONFIG"; @@ -373,14 +373,14 @@ struct high_match_rate_thread_para { int thread_id; Maat_feather_t feather; + const char* expr_table_name; }; void* high_match_rate_scan_thread(void *arg) { - const char* expr_table_name="HTTP_URL"; - struct high_match_rate_thread_para* para=(struct high_match_rate_thread_para*)arg; Maat_feather_t feather=para->feather; + const char* expr_table_name=para->expr_table_name; struct Maat_rule_t result; scan_status_t mid=NULL; @@ -404,6 +404,30 @@ void* high_match_rate_scan_thread(void *arg) *is_all_hit=(hit_times==test_times)?1:0; return is_all_hit; } +void* high_match_rate_update_thread(void *arg) +{ + struct high_match_rate_thread_para* para=(struct high_match_rate_thread_para*)arg; + Maat_feather_t feather=para->feather; + const int CMD_EXPR_NUM=10; + int config_id=0; + config_id=(int)Maat_cmd_incrby(feather, "TEST_SEQ", CMD_EXPR_NUM); + config_id-=CMD_EXPR_NUM; + int i=0; + char keyword_buf[128]; + struct Maat_command_batch* batch=NULL; + batch=Maat_command_batch_new(feather); + + for(i=0; iexpr_table_name, config_id+i, keyword_buf, 1); + sleep(1); + } + int* is_all_hit=(int*)malloc(sizeof(int)); + *is_all_hit=1; + return is_all_hit; +} + TEST_F(MaatCMDPerfTest, HighMatchRateOnMultiThread) { const char* expr_table_name="HTTP_URL"; @@ -429,16 +453,24 @@ TEST_F(MaatCMDPerfTest, HighMatchRateOnMultiThread) Maat_command_batch_commit(batch); sleep(4); int global_thread_num=4; - pthread_t threads[global_thread_num]; - struct high_match_rate_thread_para thread_para[global_thread_num]; - for(i=0; i