简体   繁体   English

如何使gcc为gprof生成信息?

[英]How to make gcc generate information for gprof?

I know that I should use -pg switch and run compiled program but it is not working. 我知道我应该使用-pg开关并运行编译的程序,但是它不起作用。 I am playing with cpuminer source code to learn something about Intel intrinsics and vectorization rather than for coins. 我正在玩cpuminer源代码,以学习有关Intel内在函数和向量化的知识,而不是硬币。 What to know where cpuminer spends most of run time. 要知道cpuminer在哪里花费了大部分运行时间。 I added -pg switch to CFLAGS before I ran configure. 在运行配置之前,我将-pg开关添加到CFLAGS。 I can see that gcc uses it during compilation eg: 我可以看到gcc在编译过程中使用了它,例如:

    gcc -std=gnu99 -DHAVE_CONFIG_H -I. -pthread -maes -Wall -O0 -g -pg -MT crypto/minerd-c_blake256.o -MD -MP -MF crypto/.deps/minerd-c_blake256.Tpo -c -o crypto/minerd-c_blake256.o `test -f 'crypto/c_blake256.c' || echo './'`crypto/c_blake256.c

But when I run exec no gmon.out file appears. 但是当我运行exec时,没有出现gmon.out文件。

Could you prompt me where should I check/look? 您能提示我在哪里检查/查看吗?

Just read somewhere that gmon.out is written when the program stops running. 只需在程序停止运行时读取写入gmon.out地方即可。 But mine never stops. 但是我的永不停止。 I am killing it with ^C - maybe it prevents gmon.out from being written? 我用^ C杀死了它-也许它阻止了gmon.out编写? Is there a better way to stop the program in such a way gmon.out will be written? 有没有更好的方法来停止以gmon.out这样的方式编写程序?

Here is the answer: Saving gmon.out before killing a process 答案是: 在终止进程之前保存gmon.out

Works perfectly for me as well. 也非常适合我。 Thanks everyone. 感谢大家。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM