gpt4 book ai didi

ubuntu - gprof 产生空输出

转载 作者:太空宇宙 更新时间:2023-11-03 16:41:50 24 4
gpt4 key购买 nike

我正在运行 Ubuntu 16.10 并尝试使用 gprof 分析程序。我用标志 -pg 编译,程序是单线程的。实际的编译命令是:

g++ -I. -std=c++11 -Wall -Wextra -O3 -pg -fPIC -Wno-unused-parameter -c -o build/obj/performance/stencil_application.o test/performance/stencil_application.cpp
g++ -I. -std=c++11 -Wall -Wextra -O3 -pg -Wno-unused-parameter build/obj/performance/stencil_application.o -o build/test/performance/stencil_application

程序在我运行时需要几秒钟才能完成,并生成一个名为 gmon.out 的文件。但是,当我运行 gprof ./build/test/performance/stencil_application 时,我得到的输出不包含任何数字。我只得到表标题和不同字段的解释,如下所示:

Flat profile:

Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name

% the percentage of the total running time of the
time program used by this function.

cumulative a running sum of the number of seconds accounted
seconds for by this function and those listed above it.

self the number of seconds accounted for by this
seconds function alone. This is the major sort for this
listing.

calls the number of times this function was invoked, if
this function is profiled, else blank.

self the average number of milliseconds spent in this
ms/call function per call, if this function is profiled,
else blank.

total the average number of milliseconds spent in this
ms/call function and its descendents per call, if this
function is profiled, else blank.

name the name of the function. This is the minor sort
for this listing. The index shows the location of
the function in the gprof listing. If the index is
in parenthesis it shows where it would appear in
the gprof listing if it were to be printed.

Copyright (C) 2012-2016 Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.

Call graph (explanation follows)


granularity: each sample hit covers 2 byte(s) no time propagated

index % time self children called name

This table describes the call tree of the program, and was sorted by
the total amount of time spent in each function and its children.

等等。

我也试过在不使用 -O3 和使用 -g 的情况下进行编译,但结果相同。有人知道怎么回事吗?

最佳答案

正如 Tony Beta Lambda 在上面的评论中所指出的,这是一个 bug in gcc .有两种可能的解决方法:降级到 gcc-4.9,或使用标记 -no-pie 进行编译。

关于ubuntu - gprof 产生空输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42620074/

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