n*********s 发帖数: 8 | 1 【 以下文字转载自 Programming 讨论区,原文如下 】
发信人: needreasons (walkman), 信区: Programming
标 题: GPROF problem
发信站: Unknown Space - 未名空间 (Fri Jan 21 18:56:33 2005) WWW-POST
Using gprof to profile the running time of a program, get the total time is
about 120s. At the same time, the "time" shell command gives ~180s.
In another case, the two could be ~170s and ~400s, respectively.
Should the time provided by gprof be almost the same as that counted by
"time"?
Thanks |
|
n*********s 发帖数: 8 | 2 Using gprof to profile the running time of a program, get the total time is
about 120s. At the same time, the "time" shell command gives ~180s.
In another case, the two could be ~170s and ~400s, respectively.
Should the time provided by gprof be almost the same as that counted by
"time"?
Thanks |
|
k*****l 发帖数: 34 | 3 Statistical Inaccuracy of gprof Output
Reason:
"The run-time figures that gprof gives you are based on a sampling proce
ss, so they are subject to statistical inaccuracy. "
"The sampling period that is printed at the beginning of the flat profil
e says how often samples are taken. The rule of thumb is that a run-time
figure is accurate if it is considerably bigger than the sampling perio
d. "
Solution:
"One way to get more accuracy is to give your program more (but similar)
input data so it will |
|
o*******7 发帖数: 13 | 4 用gprof做performance test,总是print出一堆iterator(如下)。怎么样才能让gprof
不去profile STL那部分的code呢?
=============
The flat profile of an analysed program begins with the
following entries:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
32.05 3.25 3.25 1037 0.00 0.00
std::_List_iterator_base::_List_iterator_base(std::_List_node_base*)
15.48 4.82 1.57 1 1.57 1.57
std::_L |
|
w***g 发帖数: 5958 | 5 我老写C++的时候喜欢像java那么写。这样所有的东西都在.h文件里。但问题是.h文件里
的那些东西在gprof下全都不见了。不知道有没有什么办法能让它们在gprof里显示出来
。 |
|
f***d 发帖数: 101 | 6 【 以下文字转载自 Programming 讨论区 】
【 原文由 felid 所发表 】
Hi,
I am working on a fortran program which includes several source files, with
multiple subroutines in each source file. For some of the subroutines, I have
conditional branches for decision making.
I am trying to use gprof on SunOs 4 to make some performance analysis.
In some of the subroutines, I have if block like this:
if (a.eq.b) then
call f1()
else
call f2()
end if
I am pretty sure that f2 will never be reached, but the gprof k |
|
k*****l 发帖数: 34 | 7 一个benchmark程序,gprof显示main程序累计用了286 seconds.实际wall clock 只有30
秒。为什么有这么大的差距啊?
Flat profile:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
22.68 64.87 64.87 6712596 0.00 0.00 binvcrhs_
18.45 117.64 52.77 202 0.26 0.26 compute_rhs_
15.02 160.61 42.97 201 0.21 0.39 y_solve_
14.49 202.06 41.45 201 0.21 0.38 z_solve_ |
|
t****t 发帖数: 6806 | 8 为什么不profile,STL不是code?
出现得多了正说明你STL用得多.想法减少凋用次数.
另外你不开-O2的?
gprof |
|
h****e 发帖数: 2125 | 9 不想看的话可以用editor把iterator部分的print out都去掉,不profile是不对地。
gprof |
|
h****e 发帖数: 2125 | 10 那你研究研究gprof把,好一点的profiler都有call graph功能。
function |
|
h******n 发帖数: 8 | 11 1, use -pg option to compile the source files
2, collect profiles by running the program
3, use gprof to dump profile info |
|
t**********g 发帖数: 3388 | 12 【 以下文字转载自 Linux 讨论区 】
发信人: thanksgiving (~灯红酒绿的上海~), 信区: Linux
标 题: 有谁用过gprof,觉得这东西有用么?
发信站: BBS 未名空间站 (Mon Mar 24 15:06:25 2008)
大家觉得这东西在实际工作中有用么?怎么感觉对于多线程不是很准确 |
|
f***d 发帖数: 101 | 13 It took about 10 hours to finish for my code, but gprof reported total
running time: 5440.32 seconds, which is much less than the total time.
I am working on SunOS, SparcStation 60. Does this imply that the process of
my code only took almost 1/5 of the cpu time slice during the simulation?
BTW: how accurate the estimation of cpu running time is? Is that possible
for me to make it as accurate as nano seconds with some other time function?
Thanks, |
|
G******i 发帖数: 5226 | 14 ☆─────────────────────────────────────☆
ihasleetcode (1337coder) 于 (Thu Jul 14 15:07:18 2011, 美东) 提到:
之前面的 Google,今天 recruiter 打来说我的 feedback 有两个非常好,但是也有一
到两个 poor feedback。 recruiter 说,下个星期二会进行 feedback review,应该
会有很多讨论(应该是指我在 borderline)。他说这时候最能帮到我的就是一些
references,google 里面的人的 references 如果足够 strong 的话,可以扭转局势。
不知道有没有已在 Google 工作的 xdjm 愿意帮忙 refer 一把。相信这里很多人都知
道我做的网站 ihas1337code,除了自己不断学习和总结面试题之外,也听说帮到了很
多人甚至拿到 offer,这里我替他们感到欣慰和开心。
如果你在 Google 工作的话,而且不怀疑我的编程能力,然后又愿意帮忙 refer,请站
内我。小弟在此无限感激!
... 阅读全帖 |
|
H******M 发帖数: 133 | 15 【 以下文字转载自 Programming 讨论区,原文如下 】
发信人: HiddenMM (HMM), 信区: Programming
标 题: Help on profiler
发信站: Unknown Space - 未名空间 (Thu Jul 15 16:00:49 2004) WWW-POST
Here is the problem. The main program A has a loop which starts another
program B. I want to see how much time is spent on a function F in B. I used
gprof to do this. But it seems gprof only records the last run of program B.
How do I get the accumulated time spent on F? Thanks alot! |
|
m***i 发帖数: 2480 | 16 To find which function is using most of the time (hot functions) use gprof.
It'll create a trace file and you can use gprof to generate a report later
on.
For a particular hot function, if you'd like to know whether it is spending
time on memory / floating point or integer instructions, use intel VTune.
If most of the time is spent in memory instructions, cache optimizations are
important (tiling, prefetching).
If there are a lot of floating point instructions, compiling it to 64 bit
binary coul |
|
q***e 发帖数: 90 | 17 You'd better add NOT to your statements! Missing
such an important word is misleading if not cheating!
The fact is that "NOT only routines can be profiled by
gprof", it implies that
"BUT ALSO something else could be profiled by gprof".
The something else includes at least "line by line
profiling", "block counting" etc.
I could hardly understand why you are saying like
that. Don't omit important words like "NOT" in your
statements if you did not intend to mislead the reader!!!
I gue |
|
c***p 发帖数: 221 | 18 编程:
1. strstr(char* str, char* substr)
与常规要求不同的是,需要返回最后一个匹配的子串
2. c++ STL 中 map 的实现细节(redblack tree). 比如, 如果删除了一个元素,以前
得到的iterator是否valid.
基础知识:
1. socket API: both client side and server side;
connect 如何setup. (three-way hand shaking protocol)
2. VLAN (没答上来)
3. tcp protocol: flow control, congestion control.
4. memory management:
how to manage; (my answer: linked list)
how to check if some address has been allocated
5. 如何debug memory leak.
我回答了很多:看ps, strace, valgrind. 最后才知道他要的是g... 阅读全帖 |
|
|
k*****l 发帖数: 34 | 20 time ./a.out 要给出三种时间的 real, user, system.
不只是系统时间。 |
|
p*u 发帖数: 2454 | 21 gprof cannot profile kernel, i used oprof but there's no call graph, sigh.
usage |
|
k**m 发帖数: 222 | 22 Many peformance tools (profiler) can do this. For example, gprof from GNU,
Vtune from Intel, and Sun's Performance Analyzer. Check their manual for usage
.
You problem seems to be a typical call-graph profiling problem. C++ may be
tricky because the function names might be changed by compilers to some
strange ones. |
|
s*********e 发帖数: 17 | 23 For Linux: gprof
For Windows: boundchecker |
|
|
q*d 发帖数: 20 | 25 Thanks very much!
It seems to me getrusage and gprof are very fancy to me. I am wondering
whether there is any basic function like counting the time from line i
to line k:
int i ; ..... .line i
...
...
int j; ...... line k
Thanks again! |
|
O******e 发帖数: 734 | 26 GNU C++: g++ -pg ...
Intel C++: icc -qp ...
Run your program a sufficient number of times to generate profiling data,
then your GNU gprof to analyze the data. |
|
|
o*******7 发帖数: 13 | 28 这样去掉是不行的吧? 我是想把iterator用的时间放到每一个调用iterator的function
里去。这样我就知道每个我自己写的function到底被调用了多少次,用了多少时间。 |
|
s******y 发帖数: 68 | 29 哪位用过的给说说. WINDOWS底下有什么类似的软件也行.
公司里cpp文件太多了, 始终看不出头绪来.
谢谢 |
|
c***d 发帖数: 996 | 30 ☆─────────────────────────────────────☆
flyingjeff (1@2) 于 (Sun Sep 3 22:04:21 2006) 提到:
for windows platform.
valgrind不能用吧?
thanks a lot!
☆─────────────────────────────────────☆
flyingjeff (1@2) 于 (Mon Sep 4 00:28:23 2006) 提到:
thanks a lot!
I'll have a try.
不过我才看到,原来VC里有一个profiler,以前没用过,ft
☆─────────────────────────────────────☆
streetstone (streetstone) 于 (Thu Dec 28 05:18:12 2006) 提到:
For Linux: gprof
For Windows: boundchecker |
|
r*********r 发帖数: 3195 | 31 大家都用什么工具?
我用gprof, 但有时候发现它精度不够,小点的函数在毫秒量级都是零。
能不能让它用微秒?
很久没有用VS了,以前记得它是带profiler的,但是在 vs 2005 pro 下没找到。
where did it go? also, what's the profiler's precision? |
|
|
w***g 发帖数: 5958 | 33 可以事实gprof和gcov。不过要精确到没行代码貌似比较难。
另外,C++程序优化了以后很多东西都会被inline,所以测每个函数的运行时间都比较
困难。 |
|
|
|
|
|
J*******i 发帖数: 2162 | 38 最近需要分析一个程序的性能瓶颈,所以需要profile这个程序,分析每个function里
花的时间
以前没怎么弄过,请教大家什么工具最方便易用而且准确?gprof如何?
先谢过各位猛将~ |
|
w***g 发帖数: 5958 | 39 gprof对C++基本失效。我以前用过vtune,基本达到目的。不知道aqtime怎么样。 |
|
h*****f 发帖数: 248 | 40 用过gprof的,看了oprofiler,都不provide the time my function loses due to
cache miss for data or code block.
pref top有cache miss的数据。可是好像没有detail到the time each function loses
due to cache miss for data or code block.
有C++ profiler provides cache miss data in such detail? |
|
G*****7 发帖数: 1759 | 41 intel parallel studio has some profiling tools. i remember seeing "cache
miss" in their reports. they are free for non-commercial dev under linux,
which i guess you are in 'cuz you mentioned gprof.
loses |
|
d****i 发帖数: 4809 | 42 看看阿里的技术大拿怎么客观看待开源和闭源的:
*************************************************
陈皓:关于开源和闭源软件我个人Naive的看法
对开源软件来个可能会引发争议的观点:对于绝大多数的软件产品来说,1)闭源的软
件产品的技术含量要比开源的要大得多。2)大多数的开源软件都在抄闭源的商用软件。
首先,我先表达一下开源软件的伟大,并向开源的人们致于我最真诚的敬意。但,即使
这样,我们也要很客观的承认大多数开源软件是存在大量问题的。就像我这个人主观上
并不喜欢微软和 IBM,但是我必需要承认,没有微软和 IBM,计算机这个行业不会有今
天这样的爆炸。(插曲:我 94 年上大学选的专业是计算机科学,当时很多人都觉得计
算机专业是一个 ZB 的专业,因为几乎没有哪个企业在用电脑,但我幸运的是 95 年的
时候微软出了 Win95,Sun 出了 Java,然后互联网极度膨胀,才导致我选的专业最终
变得很火)。
至于我说的这两句话,我知道是有争议的,尤其是我用了“抄”,在此请原谅我用词不
当,像从事开源的朋友道歉。这个“抄”其实是“模仿”的意... 阅读全帖 |
|
h******a 发帖数: 198 | 43 play with linux , play with different shells, play
with various tools(awk,perl,sed,lex,yacc,gnuplot,vi,make
,gdb,gcc,RCS,gprof,expect,Tcl/Tk,...)
BTW, u should learn emacs first. I began to love
UNIX after I mastered 30% of emacs.
Then, you could begin to learn UNIX system programming
and hack around its kernel....(I am on the way too)
The strongest recommended Book:
Kernighan & Pike <>
If you are truly interested, you can visit the website to
hear the suggestion |
|
|
q***e 发帖数: 90 | 45 Try gprof. Could achieve most of your demand |
|
t******q 发帖数: 117 | 46 only routines can be profiled by gprof.
instruction |
|
c*****t 发帖数: 1879 | 47 Do a print statement in f2() and check. |
|
f***d 发帖数: 101 | 48 【 以下文字转载自 Programming 讨论区 】
【 原文由 felid 所发表 】
sorry, found what went wrong, used the wrong executable for profiling,
this tool is nice.
thanks, |
|
f***d 发帖数: 101 | 49 it did not work automatically on my Sun workstation, I mean the make file
of cvg, anyone tried it? how was the drawing?
3x, |
|
l******t 发帖数: 108 | 50 i remember I used it before but forgot how to make it working.
what do you mean by the make file of cvg? it can't compile? |
|