gpt4 book ai didi

c - gprof 是否考虑了被阻止的时间?

转载 作者:行者123 更新时间:2023-12-04 07:00:20 26 4
gpt4 key购买 nike

我在我的可执行文件上运行 gprof,但该可执行文件花费了大量时间 wait() ing 以完成子进程。等待时间是否计入 gprof 时间?

最佳答案

我没有经常使用 gprof,但据我所知,wait 也没有。也不会对每个看到的子进程进行概要分析。

看一个简单的例子:

#include <stdlib.h>
#include <unistd.h>
#include <limits.h>

void slow_function()
{
unsigned int i;
for (i = 0; i < UINT_MAX; i++);
}

void quick_function(pid_t child)
{
int status;
waitpid(child, &status, 0);
return;
}

int main(int argc, const char *argv[])
{
pid_t child;

child = fork();
if (child == 0) // child process
{
slow_function();
exit(0);
}
else
quick_function(child);

return 0;
}
gprof输出是(在我的机器上):
  %   cumulative   self              self     total
time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 1 0.00 0.00 quick_function

如果你真的想分析 child /线程,我建议 this作为起点。

关于c - gprof 是否考虑了被阻止的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1969578/

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