Cantera
Install
User Guide
Examples
Reference
Develop
Community
4.0.0a2
Toggle main menu visibility
Loading...
Searching...
No Matches
clockWC.h
Go to the documentation of this file.
1
/**
2
* @file clockWC.h
3
* Declarations for a simple class that implements an Ansi C wall clock timer
4
* (see @ref Cantera::clockWC).
5
*/
6
7
// This file is part of Cantera. See License.txt in the top-level directory or
8
// at https://cantera.org/license.txt for license and copyright information.
9
10
#ifndef CT_CLOCKWC_H
11
#define CT_CLOCKWC_H
12
13
#include <time.h>
14
namespace
Cantera
15
{
16
17
//! @defgroup globalUtilFuncs Global Utility Functions
18
19
//! The class provides the wall clock timer in seconds
20
/*!
21
* This routine relies on the ANSI C routine, clock(), for its basic operation.
22
* Therefore, it should be fairly portable.
23
*
24
* The clock will rollover if the calculation is long enough. The wraparound
25
* time is roughly 72 minutes for a 32 bit system. This object senses that by
26
* seeing if the raw tick counter is has decreased from the last time. If it
27
* senses a wraparound has occurred, it increments an internal counter to
28
* account for this. Therefore, for long calculations, this object must be
29
* called at regular intervals for the seconds timer to be accurate.
30
*
31
* An example of how to use the timer is given below. timeToDoCalcs contains the
32
* wall clock time calculated for the operation.
33
*
34
* @code
35
* clockWC wc;
36
* do_hefty_calculations_atLeastgreaterThanAMillisecond();
37
* double timeToDoCalcs = wc.secondsWC();
38
* @endcode
39
*
40
* In general, the process to be timed must take more than a millisecond for
41
* this clock to enough of a significant resolution to be accurate.
42
*
43
* @ingroup globalUtilFuncs
44
*
45
*/
46
class
clockWC
47
{
48
public
:
49
//! Constructor
50
/*!
51
* This also serves to initialize the ticks within the object
52
*/
53
clockWC
();
54
55
//! Resets the internal counters and returns the wall clock time in seconds
56
double
start
();
57
58
//! Returns the wall clock time in seconds since the last reset.
59
/*!
60
* Returns system cpu and wall clock time in seconds. This is a strictly
61
* Ansi C timer, since clock() is defined as an Ansi C function. On some
62
* machines clock() returns type unsigned long (HP) and on others (SUN)
63
* it returns type long. An attempt to recover the actual time for clocks
64
* which have rolled over is made also. However, it only works if this
65
* function is called fairly regularly during the solution procedure.
66
*/
67
double
secondsWC
();
68
69
private
:
70
//! Counters the value of the number of ticks from the last call.
71
clock_t
last_num_ticks
;
72
73
//! Number of clock rollovers since the last initialization
74
/*!
75
* The clock will rollover if the calculation is long enough. This object
76
* senses that by seeing if the raw tick counter is has decreased from the
77
* last time.
78
*/
79
unsigned
int
clock_rollovers
;
80
81
//! Counter containing the value of the number of ticks from the first call
82
//! (or the reset call).
83
clock_t
start_ticks
;
84
85
//! internal constant containing clock ticks per second
86
const
double
inv_clocks_per_sec
;
87
88
//! internal constant containing the total number of ticks per rollover.
89
const
double
clock_width
;
90
};
91
}
92
#endif
Cantera::clockWC::last_num_ticks
clock_t last_num_ticks
Counters the value of the number of ticks from the last call.
Definition
clockWC.h:71
Cantera::clockWC::start
double start()
Resets the internal counters and returns the wall clock time in seconds.
Definition
clockWC.cpp:25
Cantera::clockWC::clock_rollovers
unsigned int clock_rollovers
Number of clock rollovers since the last initialization.
Definition
clockWC.h:79
Cantera::clockWC::start_ticks
clock_t start_ticks
Counter containing the value of the number of ticks from the first call (or the reset call).
Definition
clockWC.h:83
Cantera::clockWC::secondsWC
double secondsWC()
Returns the wall clock time in seconds since the last reset.
Definition
clockWC.cpp:32
Cantera::clockWC::inv_clocks_per_sec
const double inv_clocks_per_sec
internal constant containing clock ticks per second
Definition
clockWC.h:86
Cantera::clockWC::clockWC
clockWC()
Constructor.
Definition
clockWC.cpp:15
Cantera::clockWC::clock_width
const double clock_width
internal constant containing the total number of ticks per rollover.
Definition
clockWC.h:89
Cantera
Namespace for the Cantera kernel.
Definition
AnyMap.cpp:595
include
cantera
base
clockWC.h
Generated by
1.17.0