16 #if !defined(KRATOS_TIMER_H_INCLUDED )
17 #define KRATOS_TIMER_H_INCLUDED
24 #include <unordered_map>
62 class KRATOS_API(KRATOS_CORE)
Timer
75 double mTotalElapsedTime;
79 TimerData() : mRepeatNumber(
int()), mStartTime(
double()), mTotalElapsedTime(
double()), mMaximumTime(
double()), mMinimumTime(
double()) {}
84 void SetStartTime(
double StartTime)
86 mStartTime = StartTime;
88 double GetTotalElapsedTime()
90 return mTotalElapsedTime;
92 void SetTotalElapsedTime(
double TotalElapsedTime)
94 mTotalElapsedTime = TotalElapsedTime;
96 void Update(
double StopTime)
98 double elapsed = StopTime - mStartTime;
99 if(mRepeatNumber == 0)
100 mMinimumTime = elapsed;
101 mTotalElapsedTime += elapsed;
102 if(mMaximumTime < elapsed)
103 mMaximumTime = elapsed;
105 if((mMinimumTime > elapsed))
106 mMinimumTime = elapsed;
112 void PrintData(std::ostream& rOStream,
double GlobalElapsedTime = -1.00)
const;
132 static constexpr std::size_t NumberOfZeros = 3;
159 static void Start(std::string
const& rIntervalName);
165 static void Stop(std::string
const& rIntervalName);
172 const auto current_time = std::chrono::steady_clock::now();
173 return std::chrono::duration_cast<std::chrono::duration<double>>(current_time.time_since_epoch()).
count();
179 static inline double ElapsedSeconds(
const std::chrono::steady_clock::time_point StartTime)
181 const auto current_time = std::chrono::steady_clock::now();
182 return std::chrono::duration_cast<std::chrono::duration<double>>(current_time - StartTime).
count();
193 static int SetOuputFile(std::string
const& rOutputFileName);
198 static int CloseOuputFile();
204 static bool GetPrintOnScreen();
210 static void SetPrintOnScreen(
bool const PrintOnScreen);
216 static bool GetPrintIntervalInformation();
222 static void SetPrintIntervalInformation(
bool const PrintIntervalInformation);
239 static void PrintIntervalInformation(
240 std::ostream& rOStream,
241 std::string
const& rIntervalName,
242 const double StartTime,
243 const double StopTime
252 static void PrintIntervalInformation(
253 std::string
const& rIntervalName,
254 const double StartTime,
255 const double StopTime
270 virtual std::string
Info()
const
326 static InternalNameDatabaseType msInternalNameDatabase;
330 static std::ofstream msOutputFile;
332 static std::size_t msCounter;
334 static bool msPrintOnScreen;
336 static bool msPrintIntervalInformation;
338 static const std::chrono::steady_clock::time_point mStartTime;
353 static std::string GetInternalName(
const std::string& rName);
355 static std::vector<std::string>& GetLabelsStackInstance()
357 static std::vector<std::string> instance;
361 static std::string CreateFullLabel(){
362 const auto& r_labels_stack = GetLabelsStackInstance();
364 for(
const auto& r_label : r_labels_stack){
365 result +=
"/" + r_label;
418 rOStream << std::endl;
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
This utility can be used to compute the time employed on computations.
Definition: timer.h:63
static double GetTime()
This method returns the resulting time.
Definition: timer.h:170
virtual ~Timer()
Destructor.
Definition: timer.h:142
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: timer.h:281
virtual std::string Info() const
Turn back information as a string.
Definition: timer.h:270
std::map< std::string, TimerData > ContainerType
The timer data container type (map)
Definition: timer.h:126
KRATOS_CLASS_POINTER_DEFINITION(Timer)
Pointer definition of Timer.
double TimeType
The type of float used to store the time.
Definition: timer.h:123
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: timer.h:276
std::unordered_map< std::string, std::string > InternalNameDatabaseType
This is used to know the internal name used for the time table.
Definition: timer.h:129
static double ElapsedSeconds(const std::chrono::steady_clock::time_point StartTime)
This method returns the resulting time.
Definition: timer.h:179
void PrintTimingInformation(Timer &rTimer)
Definition: add_other_utilities_to_python.cpp:105
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
int count
Definition: generate_frictional_mortar_condition.py:212
Configure::ContainerType ContainerType
Definition: transfer_utility.h:247