This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: gprof - output
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: Rajesh Munavalli <munavallirv at ornl dot gov>
- Cc: bug-binutils at gnu dot org, binutils at sources dot redhat dot com
- Date: 29 Mar 2004 11:55:54 -0500
- Subject: Re: gprof - output
- References: <1080578754.2165.7.camel@capricorn.csm.ornl.gov>
Rajesh Munavalli <munavallirv@ornl.gov> writes:
> I wrote a small program to analyze the execution profile and
> understand the usage of gprof. I had "clock()" function to time the
> execution along with "gprof" option. Here are the results
>
> gprof output:
> -------------
> Each sample counts as 0.01 seconds.
> % cumulative self self total
> time seconds seconds calls ms/call ms/call name
> 77.04 6.04 6.04 100 60.40 60.40 testChar()
> 22.96 7.84 1.80 100 18.00 18.00 testStr()
>
> clock output:
> -------------
> testChar 6 seconds
> testStr 55 seconds
>
>
> The results of both are inverse proportional. Could you please explain
> the discrepancy in the gprof output?. Or is there something wrong with
> the way I am timing the program.
You are reading the results incorrectly. Your use of clock is
measuring what the gprof output describes as "cumulative seconds". In
that column you will see that testStr does that longer than testChar,
although admittedly not in the same proportion. The "%" column is the
percentage of execution time taken by that function alone. testChar
does almost all the work in the function itself; testStr does most of
the work by calling std::string functions.
Ian