Teamcenter C++ API Reference  2312
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Timer Class Reference

A simple wrapper over the SYSS CLOCK timer functions. More...

#include <Timer.hxx>

Public Member Functions

const char * elapsedString () const
 
char * logElapsedString (const char *text) const
 
void readTimer (TIMER_CLOCK_timer_values_t &values) const
 
void reset ()
 
void start ()
 
void stop ()
 
 Timer (logical startNow=true)
 
 ~Timer ()
 

Static Public Member Functions

static bool isLoginTimerEnabled ()
 

Private Member Functions

Timeroperator= (const Timer &other)
 
 Timer (const Timer &other)
 

Private Attributes

char m_buffer [128]
 
unsigned short m_timer
 

Static Private Attributes

static double s_incrementalCpu
 
static double s_incrementalReal
 
static bool s_logEnabled
 
static bool s_logEnabledChecked
 

Detailed Description

A simple wrapper over the SYSS CLOCK timer functions.

Timer t( true );
// do something
cerr << "something took " << t.elapsedString() << endl;

Definition at line 40 of file Timer.hxx.

Constructor & Destructor Documentation

Timer::Timer ( logical  startNow = true)

Constructor.

Parameters
startNow(I) Specifies when the timer starts
Timer::~Timer ( )

Default destructor.

Timer::Timer ( const Timer other)
private

Private default constructor

Member Function Documentation

const char* Timer::elapsedString ( ) const

Returns the elapsed time in seconds for both the real and cpu times ( e.g. "0.998000s cpu, 1.001000s real" ).

Returns the elapsed time in seconds for both the Central Processing Unit (CPU) and real times.
The CPU time measures the amount of time for which a central processing unit (CPU) was used, while the real time includes the waiting time for input/output (I/O) operations or entering low-power (idle) mode.
The output string is in the format "[d+].[d+]s cpu,[d+].[d+]s real", e.g. "0.998000s cpu, 1.001000s real".

Note
Caller should store the returned value to another pointer because the returned pointer will be affected by the subsequent call made to this API.
static bool Timer::isLoginTimerEnabled ( )
static

Checks if login timer is enabled, using "TC_LOGIN_TIMER" preference.

char* Timer::logElapsedString ( const char *  text) const

Constructs a string output for logging.
The output string is in the format ">> Global Timer [text], cpu & real, [d+].[d+],[d+].[d+]", e.g. ">> Global Timer text, cpu & real, 0.999000, 1.001000".

Note
Caller must the returned value by calling #MEM_free.
char* str = aTimer.logElapsedString("aText");
Teamcenter::Logging::Logger::getLogger( "Teamcenter.CoreModelGeneral.tc" );
aLogger->printf( str );
Parameters
text(I) The input text to add for logging
Timer& Timer::operator= ( const Timer other)
private

Copy constructor

void Timer::readTimer ( TIMER_CLOCK_timer_values_t values) const

Returns the timer values ( CPU, children CPU and real times ).

Parameters
values(OF) The output in TIMER_CLOCK_timer_values_t structure
void Timer::reset ( )

Resets the timer.

Note
This function does not stop the timer.
void Timer::start ( )

Starts timer.

void Timer::stop ( )

Stops timer.

Member Data Documentation

char Timer::m_buffer[128]
mutableprivate

Variable for timeString

Definition at line 122 of file Timer.hxx.

unsigned short Timer::m_timer
private

The time when the Timer instance was created

Definition at line 117 of file Timer.hxx.

double Timer::s_incrementalCpu
staticprivate

Definition at line 136 of file Timer.hxx.

double Timer::s_incrementalReal
staticprivate

Definition at line 137 of file Timer.hxx.

bool Timer::s_logEnabled
staticprivate

Definition at line 134 of file Timer.hxx.

bool Timer::s_logEnabledChecked
staticprivate

Definition at line 135 of file Timer.hxx.


The documentation for this class was generated from the following file: