Cantera  2.4.0
Public Member Functions | Private Attributes | List of all members
clockWC Class Reference

The class provides the wall clock timer in seconds. More...

#include <clockWC.h>

Public Member Functions

 clockWC ()
 Constructor. More...
 
double start ()
 Resets the internal counters and returns the wall clock time in seconds. More...
 
double secondsWC ()
 Returns the wall clock time in seconds since the last reset. More...
 

Private Attributes

clock_t last_num_ticks
 Counters the value of the number of ticks from the last call. More...
 
unsigned int clock_rollovers
 Number of clock rollovers since the last initialization. More...
 
clock_t start_ticks
 Counter containing the value of the number of ticks from the first call (or the reset call). More...
 
const double inv_clocks_per_sec
 internal constant containing clock ticks per second More...
 
const double clock_width
 internal constant containing the total number of ticks per rollover. More...
 

Detailed Description

The class provides the wall clock timer in seconds.

This routine relies on the ANSI C routine, clock(), for its basic operation. Therefore, it should be fairly portable.

The clock will rollover if the calculation is long enough. The wraparound time is roughly 72 minutes for a 32 bit system. This object senses that by seeing if the raw tick counter is has decreased from the last time. If it senses a wraparound has occurred, it increments an internal counter to account for this. Therefore, for long calculations, this object must be called at regular intervals for the seconds timer to be accurate.

An example of how to use the timer is given below. timeToDoCalcs contains the wall clock time calculated for the operation.

do_hefty_calculations_atLeastgreaterThanAMillisecond();
double timeToDoCalcs = wc.secondsWC();

In general, the process to be timed must take more than a millisecond for this clock to enough of a significant resolution to be accurate.

Definition at line 44 of file clockWC.h.

Constructor & Destructor Documentation

◆ clockWC()

clockWC ( )

Constructor.

This also serves to initialize the ticks within the object

Definition at line 15 of file clockWC.cpp.

References clockWC::last_num_ticks, and clockWC::start_ticks.

Member Function Documentation

◆ start()

double start ( )

Resets the internal counters and returns the wall clock time in seconds.

Definition at line 25 of file clockWC.cpp.

References clockWC::clock_rollovers, clockWC::last_num_ticks, and clockWC::start_ticks.

◆ secondsWC()

double secondsWC ( )

Returns the wall clock time in seconds since the last reset.

Returns system cpu and wall clock time in seconds. This is a strictly Ansi C timer, since clock() is defined as an Ansi C function. On some machines clock() returns type unsigned long (HP) and on others (SUN) it returns type long. An attempt to recover the actual time for clocks which have rolled over is made also. However, it only works if this function is called fairly regularily during the solution procedure.

Definition at line 32 of file clockWC.cpp.

References clockWC::clock_rollovers, clockWC::clock_width, clockWC::inv_clocks_per_sec, clockWC::last_num_ticks, and clockWC::start_ticks.

Referenced by vcs_MultiPhaseEquil::equilibrate_TP(), VCS_SOLVE::vcs(), and VCS_SOLVE::vcs_inest_TP().

Member Data Documentation

◆ last_num_ticks

clock_t last_num_ticks
private

Counters the value of the number of ticks from the last call.

Definition at line 69 of file clockWC.h.

Referenced by clockWC::clockWC(), clockWC::secondsWC(), and clockWC::start().

◆ clock_rollovers

unsigned int clock_rollovers
private

Number of clock rollovers since the last initialization.

The clock will rollover if the calculation is long enough. This object senses that by seeing if the raw tick counter is has decreased from the last time.

Definition at line 77 of file clockWC.h.

Referenced by clockWC::secondsWC(), and clockWC::start().

◆ start_ticks

clock_t start_ticks
private

Counter containing the value of the number of ticks from the first call (or the reset call).

Definition at line 81 of file clockWC.h.

Referenced by clockWC::clockWC(), clockWC::secondsWC(), and clockWC::start().

◆ inv_clocks_per_sec

const double inv_clocks_per_sec
private

internal constant containing clock ticks per second

Definition at line 84 of file clockWC.h.

Referenced by clockWC::secondsWC().

◆ clock_width

const double clock_width
private

internal constant containing the total number of ticks per rollover.

Definition at line 87 of file clockWC.h.

Referenced by clockWC::secondsWC().


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