SI_LOAD_SHIFT为1 << 16 SI_LOAD_SHIFT constant (included by sys/sysinfo.h)

struct sysinfo sysinf;
memset(&sysinf, 0, sizeof sysinf);
if (!sysinfo(&sysinf)) {
    float f_load = 1.f / (1 << SI_LOAD_SHIFT);
    printf("load average (1 min): %.2f (%.0f%% CPU)\n",
        sysinf.loads[0] * f_load,
        sysinf.loads[0] * f_load * 100/get_nprocs());
}
本文链接地址:https://const.net.cn/546.html

标签: none

添加新评论