Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/classcasa_1_1PrecTimer.html
Дата изменения: Unknown
Дата индексирования: Mon Feb 14 21:23:33 2011
Кодировка:

Поисковые слова: п п п п п п п п п п п п р п р п р п р п р п р п р п р п р п р п р п р п р п р п
casacore: casa::PrecTimer Class Reference
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes

casa::PrecTimer Class Reference
[OS_module]

Precision timer to measure elapsed times in a cumulative way. More...

#include <PrecTimer.h>

List of all members.

Public Member Functions

 PrecTimer ()
 Construct.
 ~PrecTimer ()
 Destruct.
void start ()
 Restart the timer.
void stop ()
 Stop the timer.
void reset ()
 Reset the timer to zero.
void show () const
 Show real time on cout or a user supplied stream.
void show (std::ostream &os) const
void show (const String &) const
 Show real time on cout or a user supplied stream preceeded by the string parameter.
void show (std::ostream &os, const String &prefix) const
double getReal () const
 Get the real time (in seconds).
unsigned long long getCount () const
 Get the total number of times start/stop is done.

Private Member Functions

void print_time (std::ostream &, double time) const

Static Private Member Functions

static double get_CPU_speed_in_MHz ()

Private Attributes

union {
   long long   total_time
   struct {
      int   total_time_low
      int   total_time_high
   } 
}; 
unsigned long long count

Static Private Attributes

static double CPU_speed_in_MHz

Detailed Description

Precision timer to measure elapsed times in a cumulative way.

Intended use:

Public interface

Review Status

Test programs:
tPrecTimer

Synopsis

The PrecTimer supplements the Timer class. If offers a low-overhead and high-resolution interval timer for use on i386, x86_64, ia64, and powerpc platforms, using the processor's timestamp counter that is incremented each cycle. Put timer.start() and timer.stop() calls around the piece of code to be timed. Because the timer is cumulative, the total time of a particular piece of code can be timed.
Caution: Make sure that start() and stop() calls alternate, otherwise very strange times will be the result;

A timer can be started and stopped multiple times; both the average and total time, as well as the number of iterations are printed. The measured time is real time (as opposed to user or system time). The timer can be used to measure from 10 nanosecond to a century interval.

Multiple timers can be used in a nested way as long as each of them has independent (matching) start and stop calls.

The class is more or less a copy of the original written by John Romein at ASTRON, Dwingeloo, the Netherlands.

Example

Here's how to create a timer, start it (the 'mark' member function) and display a breakdown.

     PrecTimer ttimer;   // the timer is reset at construction time
     PrecTimer ctimer;
     ttimer.reset();     // if you want to reset the timer (not needed here)
     ttimer.start();     // start the total timer
     for (int i=0; i<n; ++i) {
       ... do something ..\.
       ctimer.start();   // start the calc timer
       ...do some calculation which will be timed..\.
       ctimer.stop();    // and stop it
     }
     ttimer.stop();
     ttimer.show (cout, "Total       ");
     ctimer.show (cout, "Calculations");

Definition at line 100 of file PrecTimer.h.


Constructor & Destructor Documentation

casa::PrecTimer::PrecTimer (  )  [inline]

Construct.

Definition at line 177 of file PrecTimer.h.

References reset().

casa::PrecTimer::~PrecTimer (  )  [inline]

Destruct.

Definition at line 182 of file PrecTimer.h.


Member Function Documentation

static double casa::PrecTimer::get_CPU_speed_in_MHz (  )  [static, private]
unsigned long long casa::PrecTimer::getCount (  )  const [inline]

Get the total number of times start/stop is done.

Definition at line 172 of file PrecTimer.h.

References count.

double casa::PrecTimer::getReal (  )  const

Get the real time (in seconds).

void casa::PrecTimer::print_time ( std::ostream &  ,
double  time 
) const [private]
void casa::PrecTimer::reset (  )  [inline]

Reset the timer to zero.

Definition at line 166 of file PrecTimer.h.

References count, and total_time.

Referenced by PrecTimer().

void casa::PrecTimer::show ( std::ostream &  os,
const String prefix 
) const
void casa::PrecTimer::show (  )  const

Show real time on cout or a user supplied stream.

void casa::PrecTimer::show ( std::ostream &  os  )  const
void casa::PrecTimer::show ( const String  )  const

Show real time on cout or a user supplied stream preceeded by the string parameter.

void casa::PrecTimer::start (  )  [inline]

Restart the timer.

Definition at line 186 of file PrecTimer.h.

References total_time, total_time_high, and total_time_low.

void casa::PrecTimer::stop (  )  [inline]

Stop the timer.

Definition at line 260 of file PrecTimer.h.

References count, total_time, total_time_high, and total_time_low.


Member Data Documentation

union { ... } [private]
unsigned long long casa::PrecTimer::count [private]

Definition at line 157 of file PrecTimer.h.

Referenced by getCount(), reset(), and stop().

double casa::PrecTimer::CPU_speed_in_MHz [static, private]

Definition at line 160 of file PrecTimer.h.

Definition at line 139 of file PrecTimer.h.

Referenced by reset(), start(), and stop().

Definition at line 144 of file PrecTimer.h.

Referenced by start(), and stop().

Definition at line 144 of file PrecTimer.h.

Referenced by start(), and stop().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines