linux - Linux 中进程的 CPU 争用(等待时间)

标签 linux performance cpu-usage

如何检查 Linux 机器中进程等待 CPU 的时间?

例如,在加载的系统中我想检查 SQL*Loader 有多长(sqlldr) 进程等待。

如果有一个命令行工具来执行此操作将会很有用。

最佳答案

我很快就把它放在一起了。它从任务切换中打印出最小和最大的“干扰”……

#include <sys/time.h>
#include <stdio.h>

double seconds()
{
    timeval t;
    gettimeofday(&t, NULL);
    return t.tv_sec + t.tv_usec / 1000000.0;
}

int main()
{
    double min = 999999999, max = 0;
    while (true)
    {
        double c = -(seconds() - seconds());
        if (c < min)
        {
            min = c;
            printf("%f\n", c);
            fflush(stdout);
        }
        if (c > max)
        {
            max = c;
            printf("%f\n", c);
            fflush(stdout);
        }
    }

    return 0;
}

关于linux - Linux 中进程的 CPU 争用(等待时间),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3239118/

相关文章:

visual-studio - 在 Visual Studio 中调试时在内存使用中启用实时图形

c# - 提高长时间操作的性能

linux - 从 Marathon 中销毁应用程序会将其放入部署中。如何在马拉松比赛中销毁应用程序?

regex - 考虑到特殊的正则表达式,如何正确使用 sed 替换命令的反向引用

javascript - 添加超过 10 个系列时 Highcharts 性能下降

c++ - 该程序在 main() 上的 'return;' 之后需要很长时间才能关闭

linux - Azure VM 上的 cPanel?

mysql - mysql 转储成功后收到电子邮件

performance - 有什么方法可以创建 unmemo-monad?

amazon-web-services - 一周运行后,Elastic Beanstalk的CPU负载很高