Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
Teuchos_Time.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Teuchos: Common Tools Package
4
//
5
// Copyright 2004 NTESS and the Teuchos contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
// Kris
11
// 07.08.03 -- Move into Teuchos package/namespace
12
13
#ifndef _TEUCHOS_TIME_HPP_
14
#define _TEUCHOS_TIME_HPP_
15
19
20
#include "
Teuchos_ConfigDefs.hpp
"
21
22
#include <ctime>
23
#ifdef HAVE_MPI
24
#include <mpi.h>
25
#else
26
#if ICL || defined(_WIN32)
27
#include <time.h>
28
#else
29
#include <sys/time.h>
30
#ifndef MINGW
31
#include <sys/resource.h>
32
#endif
33
#endif
34
#endif
35
36
37
namespace
Teuchos
{
38
39
53
class
TEUCHOSCORE_LIB_DLL_EXPORT
Time
{
54
public
:
60
Time
(
const
std::string&
name
,
bool
start
=
false
);
61
67
static
double
wallTime
();
68
75
void
start
(
bool
reset
=
false
);
76
78
double
stop
();
79
81
void
disable
();
82
84
void
enable
();
85
87
bool
isEnabled
()
const
{
88
return
enabled_;
89
}
90
102
double
totalElapsedTime (
bool
readCurrentTime =
false
)
const
;
103
105
void
reset ();
106
112
bool
isRunning
()
const
{
113
return
isRunning_;
114
}
115
117
const
std::string&
name
()
const
{
118
return
name_;
119
}
120
123
void
incrementNumCalls();
124
126
int
numCalls
()
const
{
return
numCalls_;}
127
128
private
:
129
double
startTime_;
130
double
totalTime_;
131
bool
isRunning_;
132
bool
enabled_;
133
std::string name_;
134
int
numCalls_;
135
#ifdef HAVE_TEUCHOS_TIME_MASSIF_SNAPSHOTS
136
// We don't want to rely on incrementNumCalls being called,
137
// because this does not seem to always happen in the same order.
138
// Sometimes after start() is called, sometimes after stop().
139
int
numCallsMassifSnapshots_;
140
#endif
141
};
142
143
144
}
// namespace Teuchos
145
146
147
#endif
// TEUCHOS_TIME_HPP_
Teuchos_ConfigDefs.hpp
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
Teuchos::Time::numCalls
int numCalls() const
The number of times this timer has been called while enabled.
Definition
Teuchos_Time.hpp:126
Teuchos::Time::isEnabled
bool isEnabled() const
Whether the timer is enabled (see disable()).
Definition
Teuchos_Time.hpp:87
Teuchos::Time::enable
void enable()
"Enable" this timer, so that it (again) respects calls to start() and stop().
Definition
Teuchos_Time.cpp:158
Teuchos::Time::name
const std::string & name() const
The name of this timer.
Definition
Teuchos_Time.hpp:117
Teuchos::Time::reset
void reset()
Reset the cummulative time and call count.
Definition
Teuchos_Time.cpp:149
Teuchos::Time::start
void start(bool reset=false)
Start the timer, if the timer is enabled (see disable()).
Definition
Teuchos_Time.cpp:86
Teuchos::Time::stop
double stop()
Stop the timer, if the timer is enabled (see disable()).
Definition
Teuchos_Time.cpp:112
Teuchos::Time::isRunning
bool isRunning() const
Whether the timer is currently running.
Definition
Teuchos_Time.hpp:112
Teuchos::Time::disable
void disable()
"Disable" this timer, so that it ignores calls to start() and stop().
Definition
Teuchos_Time.cpp:154
Teuchos::Time::Time
Time(const std::string &name, bool start=false)
Constructor.
Definition
Teuchos_Time.cpp:77
Teuchos::Time::wallTime
static double wallTime()
Current wall-clock time in seconds.
Definition
Teuchos_Time.cpp:168
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Generated by
1.17.0