linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* using the correct tool to time my program
@ 2007-06-09  5:18 Mark Farnell
  2007-06-09 13:32 ` Glynn Clements
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Farnell @ 2007-06-09  5:18 UTC (permalink / raw)
  To: linux-c-programming

I have a parallel program, which calls some message passing functions
which block.  Then I attempted to use times() (with struct tms) to
time the program.

the struct tms gives me the "program time" and the "system time" as
well as the child process time (if any).  However does it also include
the time spent when my program is blocked (i.e. network time).

This is important because although I use gprof to separate the CPU
time spent by my program vs libraries, when I calculate the total time
spent, I really need to include the time spent waiting for message
from network (network time).

Therefore is times() really appropriate for my purpose?  If not, what
other functions can I use instead? (such as gettimeofday?)

Thanks!

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: using the correct tool to time my program
  2007-06-09  5:18 using the correct tool to time my program Mark Farnell
@ 2007-06-09 13:32 ` Glynn Clements
  0 siblings, 0 replies; 2+ messages in thread
From: Glynn Clements @ 2007-06-09 13:32 UTC (permalink / raw)
  To: Mark Farnell; +Cc: linux-c-programming


Mark Farnell wrote:

> I have a parallel program, which calls some message passing functions
> which block.  Then I attempted to use times() (with struct tms) to
> time the program.
> 
> the struct tms gives me the "program time" and the "system time" as
> well as the child process time (if any).  However does it also include
> the time spent when my program is blocked (i.e. network time).

No. times() measures CPU usage; any time spent idle isn't measured. 
Ditto for getrusage().

> This is important because although I use gprof to separate the CPU
> time spent by my program vs libraries, when I calculate the total time
> spent, I really need to include the time spent waiting for message
> from network (network time).
> 
> Therefore is times() really appropriate for my purpose?  If not, what
> other functions can I use instead? (such as gettimeofday?)

If you need to measure real time (aka "wall-clock time"), use
gettimeofday() or clock_gettime().

-- 
Glynn Clements <glynn@gclements.plus.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-09 13:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-09  5:18 using the correct tool to time my program Mark Farnell
2007-06-09 13:32 ` Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).