Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Timer.hh File Reference
#include <sys/times.h>
#include <unistd.h>
#include "G4Types.hh"
#include "G4ios.hh"
#include <chrono>
#include "G4Timer.icc"

Go to the source code of this file.

Classes

class  G4Timer
 

Functions

std::ostream & operator<< (std::ostream &os, const G4Timer &t)
 

Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const G4Timer t 
)

Definition at line 84 of file G4Timer.cc.

85{
86 // so fixed doesn't propagate
87 std::stringstream ss;
88 ss << std::fixed;
89 if(t.IsValid())
90 {
91 ss << "User=" << t.GetUserElapsed() << "s Real=" << t.GetRealElapsed()
92 << "s Sys=" << t.GetSystemElapsed() << "s";
93#ifdef G4MULTITHREADED
94 // avoid possible FPE error
95 if(t.GetRealElapsed() > 1.0e-6)
96 {
97 G4double cpu_util = (t.GetUserElapsed() + t.GetSystemElapsed()) /
98 t.GetRealElapsed() * 100.0;
99 ss << std::setprecision(1);
100 ss << " [Cpu=" << std::setprecision(1) << cpu_util << "%]";
101 }
102#endif
103 }
104 else
105 {
106 ss << "User=****s Real=****s Sys=****s";
107 }
108 os << ss.str();
109
110 return os;
111}
double G4double
Definition: G4Types.hh:83
G4double GetSystemElapsed() const
Definition: G4Timer.cc:124
G4bool IsValid() const
G4double GetUserElapsed() const
Definition: G4Timer.cc:135
G4double GetRealElapsed() const
Definition: G4Timer.cc:113