gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:01:27 29 4
gpt4 key购买 nike

如何检查 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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com