✨ feat(MESA_handle_runtime_log_level_enabled): log_handle_t改为前置声明,增加判断level是否启用的接口
This commit is contained in:
@@ -16,6 +16,7 @@ void *test_handle = NULL;
|
||||
int g_mode = 0;
|
||||
int g_log_num = 0;
|
||||
int g_thread_num = 0;
|
||||
int g_sleep_interval = 0;
|
||||
const char *g_zlog_conf = NULL;
|
||||
volatile long g_start_time = 0;
|
||||
volatile long g_end_time = 0;
|
||||
@@ -44,7 +45,11 @@ void call_logger(int log_num, int thread_num)
|
||||
//sleep(1);
|
||||
MESA_handle_runtime_log(test_handle, RLOG_LV_INFO, "test", "test_handle MESA_handle_runtime_log, i = %d, thread_num = %d", i, thread_num);
|
||||
//MESA_HANDLE_RUNTIME_LOG(sample_handle, RLOG_LV_FATAL, "sample", "sample_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||
//sleep(1);
|
||||
if(g_sleep_interval > 0)
|
||||
{
|
||||
printf("MESA_handle_runtime_log_level_enabled(%d) return %d\n", RLOG_LV_DEBUG, MESA_handle_runtime_log_level_enabled(test_handle, RLOG_LV_DEBUG));
|
||||
sleep(g_sleep_interval);
|
||||
}
|
||||
//MESA_HANDLE_RUNTIME_LOG(test_handle, RLOG_LV_FATAL, "test", "test_handle RUNTIEM_LOG test, i = %d, thread_num = %d", i, thread_num);
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||
@@ -60,8 +65,9 @@ void call_logger(int log_num, int thread_num)
|
||||
g_end_time = end_time;
|
||||
}
|
||||
}
|
||||
time_cost = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000 ;
|
||||
time_cost = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000 - g_sleep_interval * 1000000 ;
|
||||
printf("THREAD %d write %d log using %ld us, avg speed %f /s, %ld -> %ld\n", thread_num, log_num, time_cost, ((float)log_num/(float)time_cost)*1000000, start_time, end_time);
|
||||
printf("MESA_handle_runtime_log_level_enabled(%d) return %d\n", RLOG_LV_DEBUG, MESA_handle_runtime_log_level_enabled(test_handle, RLOG_LV_DEBUG));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -101,15 +107,16 @@ int main(int argc, char ** args)
|
||||
pthread_t t[MAX_THREAD_NUM];
|
||||
int i = 0;
|
||||
|
||||
if (argc != 5)
|
||||
if (argc != 6)
|
||||
{
|
||||
printf("Usage: ./($app) $mode[1 or 2] $zlog_conf_path $thread_num $log_num \n");
|
||||
printf("Usage: ./($app) $version_mode[1 or 2] $zlog_conf_path $thread_num $log_num $sleep_interval\n");
|
||||
return -1;
|
||||
}
|
||||
g_mode = atoi(args[1]);
|
||||
g_zlog_conf = args[2];
|
||||
g_thread_num = atoi(args[3]);
|
||||
g_log_num = atoi(args[4]);
|
||||
g_sleep_interval = atoi(args[5]);
|
||||
|
||||
if(g_thread_num <= 0 || g_log_num <= 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user