linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Measuring cpu time using getrusage
@ 2007-02-14 13:17 Johann Schuster
  2007-02-17 12:09 ` Tim Schmielau
  0 siblings, 1 reply; 2+ messages in thread
From: Johann Schuster @ 2007-02-14 13:17 UTC (permalink / raw)
  To: linux-kernel

Hello,

currently i'm trying to measure the cpu times for
numerical algorithms written in C using two calls of
getrusage() and then calculating the time difference.

According to the man page of getrusage i looked at the
user time of my process. Surprisingly the measured user
times vary strongly depending on the system load of the
machine.
A heavy system load nearly doubles the measured time
for my routine.

Does anyone know a better way to measure the used
cpu cycles of a given process (or part of a program)
or can anyone give me a hint if i missed some important
fact.

Any help appreciated. Thank you in advance.


Johann Schuster

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

* Re: Measuring cpu time using getrusage
  2007-02-14 13:17 Measuring cpu time using getrusage Johann Schuster
@ 2007-02-17 12:09 ` Tim Schmielau
  0 siblings, 0 replies; 2+ messages in thread
From: Tim Schmielau @ 2007-02-17 12:09 UTC (permalink / raw)
  To: Johann Schuster; +Cc: linux-kernel

On Wed, 14 Feb 2007, Johann Schuster wrote:

> currently i'm trying to measure the cpu times for
> numerical algorithms written in C using two calls of
> getrusage() and then calculating the time difference.
> 
> According to the man page of getrusage i looked at the
> user time of my process. Surprisingly the measured user
> times vary strongly depending on the system load of the
> machine.
> A heavy system load nearly doubles the measured time
> for my routine.

Does your system have hyperthreading? (look at whether the siblings field 
in /proc/cpuinfo is greater than one)
If yes, there is no way to accurately measure runtimes because the 
(single-threaded) performance of your CPU depends on the other tasks 
running. Just disable hyperthreading for these measurements.

Tim

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

end of thread, other threads:[~2007-02-17 12:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-14 13:17 Measuring cpu time using getrusage Johann Schuster
2007-02-17 12:09 ` Tim Schmielau

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).