Unix Programming - benchmark tool?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > June 2004 > benchmark tool?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author benchmark tool?
pembed2003

2004-06-26, 10:11 am

Hi all,
I have written a few programs in C/C++ but some of them are slow and I
need to find out where most of the execution time is spend. Do you
know of any tool that reports that? Like it will tell me that my
function foo is taking up 90% of the time or this loop is only using
1% of the time, etc. Thanks!
sean larsson

2004-06-26, 10:11 am

On 22 Jun 2004 17:56:11 -0700
pembed2003@yahoo.com (pembed2003) wrote:

> Hi all,
> I have written a few programs in C/C++ but some of them are slow and I
> need to find out where most of the execution time is spend. Do you
> know of any tool that reports that? Like it will tell me that my
> function foo is taking up 90% of the time or this loop is only using
> 1% of the time, etc. Thanks!


man gprof. and if u google for profilers you'll find other stuff. those tools will tell you what functions are taking up time, but if you want to get specific as to what loops are doing what, u need something else. there is a tool that intel provides fo
r intels only obviously. it is pretty in depth, but not free. i wrote a tool for doing this, it works on pentiums and uses the rdtsc instruction. see here: http://forums.devshed.com/t108319/s.html

--
-sean
Nick Landsberg

2004-06-26, 10:11 am

sean larsson wrote:
> On 22 Jun 2004 17:56:11 -0700
> pembed2003@yahoo.com (pembed2003) wrote:
>
>
>
>
> man gprof. and if u google for profilers you'll find other stuff. those tools will tell you what functions are taking up time, but if you want to get specific as to what loops are doing what, u need something else. there is a tool that intel provides

for intels only obviously. it is pretty in depth, but not free. i wrote a tool for doing this, it works on pentiums and uses the rdtsc instruction. see here: http://forums.devshed.com/t108319/s.html
>


As a first step "gprof" is pretty good in that it tell you what
routines are being called most often and take up the most
time. At least you can narrow it down that way.

Example: 98% of the time is being spent in routine foobar().

Choices:
1. Call foobar() less often
2. Find a replacement for foobar()
3. Optimize foobar()

Choice 1 is almost always better than choice 2, in my
experience, but it's harder to do, so most folks
start right on choice 3. In a previous thread, one
poster, whose name I forgot, mentioned that he saw
someone once try to optimize the assembler for
a bubble-sort routine.

Look at both the frequency with which a routine is
called *and* the percent of total time that
the routine takes up. If all you have is one
big routine, maybe you should re-evaluate your
design decisions.

Past that, it's up to you to know how to do things
as move invariants out of loop constructs and such.

If "gprof" shows that the usage is evenly spread out
between 20 or so routines/functions/methods, you are
usually SOL.

NPL

--
"It is impossible to make anything foolproof
because fools are so ingenious"
- A. Bloch
Alex Vinokur

2004-06-26, 10:11 am


"pembed2003" <pembed2003@yahoo.com> wrote in message news:db593abd.0406221656.34036660@posting.google.com...
> Hi all,
> I have written a few programs in C/C++ but some of them are slow and I
> need to find out where most of the execution time is spend. Do you
> know of any tool that reports that? Like it will tell me that my
> function foo is taking up 90% of the time or this loop is only using
> 1% of the time, etc. Thanks!


Tool for measuring comparative performance of the C/C++ code (C/C++ Program Perfometer):

http://groups.google.com/groups?sel...s.uni-berlin.de (Brief Description)
http://article.gmane.org/gmane.comp...B.perfometer/39 (Latest : Release 2.8.0-1.18)
http://alexvn.freeservers.com/s1/pe...sts/pftests.htm (C/C++ Performance Tests)
http://news.gmane.org/group/gmane.c...t=/force_load=t (newsgroup)


--
Alex Vinokur
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn



pembed2003

2004-06-26, 10:11 am

sean larsson <infamous42md@ERASEMEhotpop.com> wrote in message news:<20040622211706.040de53a.infamous42md@ERASEMEhotpop.com>...
> On 22 Jun 2004 17:56:11 -0700
> pembed2003@yahoo.com (pembed2003) wrote:
>
>
> man gprof.
>


Hi Sean,
Thanks for pointing me to gprof. I man gprof but still can't figure
out how to use it! The executable I am trying to gprof is call 'test'
and I have tried:

$ gprof
gprof: fopen: a.out: No such file or directory

$ gprof -o test
gprof: fopen: gmon.out: No such file or directory

$ mv test a.out
$ gprof
gprof: fopen: gmon.out: No such file or directory

$ gprof -s
gprof: fopen: gmon.out: No such file or directory

$ gprof -D
gprof: fopen: gmon.out: No such file or directory

I wish the man page includes a few example of how to use the tool but
there is none. Can you give me a few pointers / examples of how to use
it?

Thanks!
sean larsson

2004-06-26, 10:11 am

On 23 Jun 2004 10:46:15 -0700
pembed2003@yahoo.com (pembed2003) wrote:

> sean larsson <infamous42md@ERASEMEhotpop.com> wrote in message news:<20040622211706.040de53a.infamous42md@ERASEMEhotpop.com>...
>
> Hi Sean,
> Thanks for pointing me to gprof. I man gprof but still can't figure
> out how to use it! The executable I am trying to gprof is call 'test'
> and I have tried:
>
> $ gprof
> gprof: fopen: a.out: No such file or directory
>
> $ gprof -o test
> gprof: fopen: gmon.out: No such file or directory
>
> $ mv test a.out
> $ gprof
> gprof: fopen: gmon.out: No such file or directory
>
> $ gprof -s
> gprof: fopen: gmon.out: No such file or directory
>
> $ gprof -D
> gprof: fopen: gmon.out: No such file or directory
>
> I wish the man page includes a few example of how to use the tool but
> there is none. Can you give me a few pointers / examples of how to use
> it?
>
> Thanks!


'info gprof' will give u the goods. i should have said that b4, my bad.

--
-sean
Brian Raiter

2004-06-26, 10:11 am

> Thanks for pointing me to gprof. I man gprof but still can't figure
> out how to use it! The executable I am trying to gprof is call 'test'
> and I have tried:


Assuming that you compiled test with profiling data, it looks like you
just forgot to run your program before calling gprof. (Either that, or
you ran gprof from a directory other than where your binary lives.)

b
pembed2003

2004-06-26, 10:11 am

blr@drizzle.com (Brian Raiter) wrote in message news:<cbd6re$e88$1@drizzle.com>...
>
> Assuming that you compiled test with profiling data, it looks like you
> just forgot to run your program before calling gprof. (Either that, or
> you ran gprof from a directory other than where your binary lives.)
>
> b


Hi Brian / Sean,
I 'info gprof' and ran my 'test' executable and now I can see what
function takes the longest time in my program. I have an additional
question:

I compiled my program with -pg so some symbles are inserted into my
program for prof, how can I strip out those symbles later on? Do I
always have to recompile without '-pg' or is there a way to strip out
the symbles?

Thanks!
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com