Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWTimer

Module:  Essential Tools Module   Group:  Miscellaneous Classes


Does not inherit

Local Index

Members

Synopsis

#include <rw/timer.h>
RWTimer timer;

Description

This class can measure two types of time: system time and user time, both of which can be reported as cumulative, if desired. The timer has two states: running and stopped. The timer measures the total amount of time spent in the "running" state since it was either constructed or reset.

The timer is put into the "running" state by calling member function start(). It is put into the "stopped" state by calling stop().

RWTimer uses different APIs on Windows and UNIX; on Windows it uses GetProcessTime, whereas on UNIX it uses the getrusage system call.

The time intervals are stored inside the RWTimer objects as 64-bit integers. The resolution of the timer is microseconds. The wrap-up interval for the counters is > 500,000 years.

Persistence

None

Example

This example prints out the amount of CPU time used while looping for 5 seconds ( of wall-clock time , as measured using class RWDateTime).

Program output (exact value may differ):

Enumeration

enum Type { userTime = 1, systemTime = 2 };

Public Constructor

RWTimer();

Public Member Functions

rwint64 
elapsedSeconds() const;
rwint64 
elapsedMilliseconds() const;
rwint64 
elapsedMicroseconds() const;
double
elapsedTime() const;
rwint64
time(int=userTime|systemTime)const;
void
reset();
void
start();
void
stop();


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.