Cantera
Install
User Guide
Examples
Reference
Develop
Community
4.0.0a2
Toggle main menu visibility
Loading...
Searching...
No Matches
clockWC.cpp
Go to the documentation of this file.
1
/**
2
* @file clockWC.cpp
3
* Definitions 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
#include <time.h>
11
#include "
cantera/base/clockWC.h
"
12
13
namespace
Cantera
14
{
15
clockWC::clockWC
() :
16
last_num_ticks
(clock()),
17
clock_rollovers
(0u),
18
start_ticks
(0),
19
inv_clocks_per_sec
(1./(double)CLOCKS_PER_SEC),
20
clock_width
((double)(1L<<((int)sizeof(clock_t)*8-2))*4./(double)CLOCKS_PER_SEC)
21
{
22
start_ticks
=
last_num_ticks
;
23
}
24
25
double
clockWC::start
()
26
{
27
start_ticks
=
last_num_ticks
= clock();
28
clock_rollovers
= 0u;
29
return
0.0;
30
}
31
32
double
clockWC::secondsWC
()
33
{
34
clock_t num_ticks = clock();
35
if
(num_ticks <
last_num_ticks
) {
36
clock_rollovers
++;
37
}
38
double
value = (num_ticks -
start_ticks
) *
inv_clocks_per_sec
;
39
if
(
clock_rollovers
) {
40
value +=
clock_rollovers
*
clock_width
;
41
}
42
last_num_ticks
= num_ticks;
43
return
value;
44
}
45
}
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
clockWC.h
Declarations for a simple class that implements an Ansi C wall clock timer (see clockWC).
Cantera
Namespace for the Cantera kernel.
Definition
AnyMap.cpp:595
src
base
clockWC.cpp
Generated by
1.17.0