OpenCAEPoro  0.2.0 Sep/22/2022
A simulator for multicomponent porous media flow
Public Member Functions | List of all members
GetWallTime Class Reference

Get elapsed wall-time in millisecond. More...

#include <UtilTiming.hpp>

Public Member Functions

__inline__ void Start ()
 Start the timer.
 
__inline__ double Stop () const
 Stop the timer and return duration from start() in ms.
 
void StopInfo (const std::string &info, std::ostream &out=std::cout) const
 Stop the timer and print out duration time. More...
 

Detailed Description

Get elapsed wall-time in millisecond.

Read the current wall-time and return duration from start() to stop().

Definition at line 31 of file UtilTiming.hpp.

Member Function Documentation

◆ StopInfo()

void GetWallTime::StopInfo ( const std::string &  info,
std::ostream &  out = std::cout 
) const

Stop the timer and print out duration time.

Stop timer and print out the duration time in ms, s, or m.

Definition at line 15 of file UtilTiming.cpp.

16 {
17  const double duration = Stop();
18  if (duration < CLOCK_USE_SEC) {
19  std::cout << info << " costs " << std::fixed << std::setprecision(3) << duration
20  << "ms" << std::endl;
21  } else if (duration < CLOCK_USE_MIN) {
22  std::cout << info << " costs " << std::fixed << std::setprecision(3)
23  << duration / 1000.0 << "s" << std::endl;
24  } else {
25  std::cout << info << " costs " << std::fixed << std::setprecision(3)
26  << duration / 60000.0 << "m" << std::endl;
27  }
28 }
const double CLOCK_USE_MIN
Show clock time in minutes.
Definition: UtilTiming.hpp:24
const double CLOCK_USE_SEC
Show clock time in seconds.
Definition: UtilTiming.hpp:23
__inline__ double Stop() const
Stop the timer and return duration from start() in ms.
Definition: UtilTiming.hpp:54

References CLOCK_USE_MIN, CLOCK_USE_SEC, and Stop().


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