Geant4-11
Public Member Functions | Private Types | Private Attributes
G4Timer Class Reference

#include <G4Timer.hh>

Public Member Functions

 G4Timer ()
 
const char * GetClockTime () const
 
G4double GetRealElapsed () const
 
G4double GetSystemElapsed () const
 
G4double GetUserElapsed () const
 
G4bool IsValid () const
 
void Start ()
 
void Stop ()
 

Private Types

using clock_type = std::chrono::high_resolution_clock
 

Private Attributes

std::chrono::time_point< clock_typefEndRealTime
 
tms fEndTimes
 
std::chrono::time_point< clock_typefStartRealTime
 
tms fStartTimes
 
G4bool fValidTimes
 

Detailed Description

Definition at line 108 of file G4Timer.hh.

Member Typedef Documentation

◆ clock_type

using G4Timer::clock_type = std::chrono::high_resolution_clock
private

Definition at line 110 of file G4Timer.hh.

Constructor & Destructor Documentation

◆ G4Timer()

G4Timer::G4Timer ( )

Definition at line 117 of file G4Timer.cc.

118 : fValidTimes(false)
119{}
G4bool fValidTimes
Definition: G4Timer.hh:124

Member Function Documentation

◆ GetClockTime()

const char * G4Timer::GetClockTime ( ) const
inline

◆ GetRealElapsed()

G4double G4Timer::GetRealElapsed ( ) const

Definition at line 121 of file G4Timer.cc.

122{
123 if(!fValidTimes)
124 {
125 G4Exception("G4Timer::GetRealElapsed()", "InvalidCondition", FatalException,
126 "Timer not stopped or times not recorded!");
127 }
128 std::chrono::duration<G4double> diff = fEndRealTime - fStartRealTime;
129 return diff.count();
130}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:35
std::chrono::time_point< clock_type > fStartRealTime
Definition: G4Timer.hh:125
std::chrono::time_point< clock_type > fEndRealTime
Definition: G4Timer.hh:125

References FatalException, fEndRealTime, fStartRealTime, fValidTimes, and G4Exception().

Referenced by export_G4Timer(), and operator<<().

◆ GetSystemElapsed()

G4double G4Timer::GetSystemElapsed ( ) const

Definition at line 132 of file G4Timer.cc.

133{
134 if(!fValidTimes)
135 {
136 G4Exception("G4Timer::GetSystemElapsed()", "InvalidCondition",
137 FatalException, "Timer not stopped or times not recorded!");
138 }
139 G4double diff = fEndTimes.tms_stime - fStartTimes.tms_stime;
140 return diff / sysconf(_SC_CLK_TCK);
141}
double G4double
Definition: G4Types.hh:83
tms fEndTimes
Definition: G4Timer.hh:126
tms fStartTimes
Definition: G4Timer.hh:126

References FatalException, fEndTimes, fStartTimes, fValidTimes, and G4Exception().

Referenced by G4ConvergenceTester::AddScore(), G4GeometryManager::BuildOptimisations(), export_G4Timer(), operator<<(), and G4RunManager::ReOptimize().

◆ GetUserElapsed()

G4double G4Timer::GetUserElapsed ( ) const

Definition at line 143 of file G4Timer.cc.

144{
145 if(!fValidTimes)
146 {
147 G4Exception("G4Timer::GetUserElapsed()", "InvalidCondition", FatalException,
148 "Timer not stopped or times not recorded");
149 }
150 G4double diff = fEndTimes.tms_utime - fStartTimes.tms_utime;
151 return diff / sysconf(_SC_CLK_TCK);
152}

References FatalException, fEndTimes, fStartTimes, fValidTimes, and G4Exception().

Referenced by G4ConvergenceTester::AddScore(), G4VXTRenergyLoss::BuildAngleForEnergyBank(), G4VXTRenergyLoss::BuildAngleTable(), G4VXTRenergyLoss::BuildEnergyTable(), G4VXTRenergyLoss::BuildGlobalAngleTable(), G4GeometryManager::BuildOptimisations(), export_G4Timer(), operator<<(), and G4RunManager::ReOptimize().

◆ IsValid()

G4bool G4Timer::IsValid ( ) const
inline

Referenced by export_G4Timer(), and operator<<().

◆ Start()

void G4Timer::Start ( )
inline

◆ Stop()

void G4Timer::Stop ( )
inline

Field Documentation

◆ fEndRealTime

std::chrono::time_point<clock_type> G4Timer::fEndRealTime
private

Definition at line 125 of file G4Timer.hh.

Referenced by GetRealElapsed().

◆ fEndTimes

tms G4Timer::fEndTimes
private

Definition at line 126 of file G4Timer.hh.

Referenced by GetSystemElapsed(), and GetUserElapsed().

◆ fStartRealTime

std::chrono::time_point<clock_type> G4Timer::fStartRealTime
private

Definition at line 125 of file G4Timer.hh.

Referenced by GetRealElapsed().

◆ fStartTimes

tms G4Timer::fStartTimes
private

Definition at line 126 of file G4Timer.hh.

Referenced by GetSystemElapsed(), and GetUserElapsed().

◆ fValidTimes

G4bool G4Timer::fValidTimes
private

Definition at line 124 of file G4Timer.hh.

Referenced by GetRealElapsed(), GetSystemElapsed(), and GetUserElapsed().


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