Geant4 10.7.0
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 88 of file G4Timer.cc.

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