use C++11 functionality to determine wall time
This commit is contained in:
@ -106,6 +106,10 @@ static const zip_info &find_zip_type(const std::string &file)
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
// set reference time stamp during executable/library init.
|
||||||
|
// should provide better resolution than using epoch, if the system clock supports it.
|
||||||
|
static auto initial_time = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
// get CPU time
|
// get CPU time
|
||||||
@ -156,22 +160,7 @@ double platform::cputime()
|
|||||||
------------------------------------------------------------------------ */
|
------------------------------------------------------------------------ */
|
||||||
double platform::walltime()
|
double platform::walltime()
|
||||||
{
|
{
|
||||||
double wtime;
|
return std::chrono::duration<double>(std::chrono::steady_clock::now() - initial_time).count();
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
|
|
||||||
wtime = GetTickCount64() * 0.001;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
struct timeval tv;
|
|
||||||
|
|
||||||
gettimeofday(&tv, nullptr);
|
|
||||||
wtime = 1.0 * tv.tv_sec + 1.0e-6 * tv.tv_usec;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return wtime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
@ -27,25 +27,30 @@ namespace platform {
|
|||||||
/*! Return the consumed CPU time for the current process in seconds
|
/*! Return the consumed CPU time for the current process in seconds
|
||||||
*
|
*
|
||||||
* This is a wrapper around the POSIX function getrusage() and its Windows equivalent.
|
* This is a wrapper around the POSIX function getrusage() and its Windows equivalent.
|
||||||
* It is to be used in a similar fashion than MPI_Wtime().
|
* It is to be used in a similar fashion than MPI_Wtime(). Its resolution may
|
||||||
|
* be rather low so it can only be trusted when observing processes consuming at
|
||||||
|
* seconds or more of CPU time.
|
||||||
*
|
*
|
||||||
* \return used CPU time in second */
|
* \return used CPU time in seconds */
|
||||||
|
|
||||||
double cputime();
|
double cputime();
|
||||||
|
|
||||||
/*! Return the wall clock state for the current process in seconds
|
/*! Return the wall clock state for the current process in seconds
|
||||||
*
|
*
|
||||||
* This is a wrapper around the gettimeofday() function and its Windows equivalent.
|
* This this clock is counting continuous time is initialized during
|
||||||
* It is to be used in a similar fashion than MPI_Wtime().
|
* Load of the executable/library. Its absolute value must be considered
|
||||||
|
* arbitrary and thus elapsed wall times are measured in taking differences.
|
||||||
|
* It is therefore to be used in a similar fashion as MPI_Wtime() but
|
||||||
|
* has a different offset, usually leading to better resolution.
|
||||||
*
|
*
|
||||||
* \return wall clock time in second */
|
* \return wall clock time in seconds */
|
||||||
|
|
||||||
double walltime();
|
double walltime();
|
||||||
|
|
||||||
|
|
||||||
/*! Suspend execution for a microsecond interval
|
/*! Suspend execution for a microsecond interval
|
||||||
*
|
*
|
||||||
* This emulates the usleep(3) BSD function call also mentioned in POSIX.1-2001.
|
* This emulates the usleep(3) BSD function call also mentioned in POSIX.1-2001.
|
||||||
|
* This is not a precise delay; it may be longer, but not shorter.
|
||||||
*
|
*
|
||||||
* \param usec length of delay in microseconds */
|
* \param usec length of delay in microseconds */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user