diff --git a/MagicEyes/src/backend/process/cpu_watcher/include/cpu_watcher_helper.h b/MagicEyes/src/backend/process/cpu_watcher/include/cpu_watcher_helper.h index 08e38f0e1..e39ac0118 100644 --- a/MagicEyes/src/backend/process/cpu_watcher/include/cpu_watcher_helper.h +++ b/MagicEyes/src/backend/process/cpu_watcher/include/cpu_watcher_helper.h @@ -52,16 +52,17 @@ bool dynamic_filter(struct ewma_info *ewma_syscall_delay, double dataPoint) { if(ewma_syscall_delay->previousEWMA == 0) {//初始化ewma算法,则赋值previousEWMA = dataPoint 并打印 ewma_syscall_delay->previousEWMA = dataPoint; - return 1; + return 0; } - if(ewma_syscall_delay->count <30){ + if(ewma_syscall_delay->count <10){ ewma_syscall_delay->previousEWMA = calculateEWMA(ewma_syscall_delay->previousEWMA,dataPoint,alpha);//计算 - return 1; + ewma_syscall_delay->count++; + return 0; } else{ ewma_syscall_delay->previousEWMA = calculateEWMA(ewma_syscall_delay->previousEWMA,dataPoint,alpha);//计算 threshold = ewma_syscall_delay->previousEWMA * TOLERANCE; - if(dataPoint >= threshold) return 1; + if(dataPoint > threshold*5) return 1; } return 0; } diff --git a/MagicEyes/src/backend/process/cpu_watcher/src/cpu_watcher.c b/MagicEyes/src/backend/process/cpu_watcher/src/cpu_watcher.c index e98bd2325..d2164262c 100644 --- a/MagicEyes/src/backend/process/cpu_watcher/src/cpu_watcher.c +++ b/MagicEyes/src/backend/process/cpu_watcher/src/cpu_watcher.c @@ -911,7 +911,7 @@ int main(int argc, char **argv) fprintf(stderr, "Failed to attach BPF skeleton\n"); goto sc_delay_cleanup; } - printf("%-8s %-8s %-15s %-15s\n","Time","Pid","syscall_id","delay/ms"); + printf("%-8s %-8s %-15s %-15s\n","Time","Pid","syscall_id","delay/us"); rb = ring_buffer__new(bpf_map__fd(sc_skel->maps.rb), syscall_delay_print, NULL, NULL); //ring_buffer__new() API,允许在不使用额外选项数据结构下指定回调 if (!rb) { err = -1;