35#ifndef _BLAZE_UTIL_TIME_H_
36#define _BLAZE_UTIL_TIME_H_
43#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR) || defined(__MINGW32__)
50# include <sys/timeb.h>
52# include <sys/resource.h>
54# include <sys/types.h>
92 localTime = std::localtime( &t );
93 std::strftime( c, 50,
"%Y-%m-%d", localTime );
95 return std::string( c );
113 localTime = std::localtime( &t );
114 std::strftime( c, 50,
"%A, %d.%B %Y, %H:%M", localTime );
116 return std::string( c );
130 struct _timeb timeptr;
131 _ftime64_s( &timeptr );
132 return (
static_cast<double>( timeptr.time ) +
static_cast<double>( timeptr.millitm )/1E3 );
135 gettimeofday( &tp,
nullptr );
136 return (
static_cast<double>( tp.tv_sec ) +
static_cast<double>( tp.tv_usec )/1E6 );
151 FILETIME CreateTime, ExitTime, KernelTime, UserTime;
154 if( GetProcessTimes( GetCurrentProcess(), &CreateTime, &ExitTime, &KernelTime, &UserTime ) != TRUE ) {
158 FileTimeToSystemTime( &UserTime, &SysTime );
159 return (
static_cast<double>( SysTime.wSecond ) +
static_cast<double>( SysTime.wMilliseconds )/1E3 );
163 getrusage( RUSAGE_SELF, &ruse );
164 return (
static_cast<double>( ruse.ru_utime.tv_sec ) +
static_cast<double>( ruse.ru_utime.tv_usec )/1E6 );
double getWcTime()
Returns the current wall clock time in seconds.
Definition: Time.h:127
double getCpuTime()
Returns the current CPU time in seconds.
Definition: Time.h:148
std::string getTime()
Creating a formated time and date string.
Definition: Time.h:106
std::string getDate()
Creating a formated date string in the form YYYY-MM-DD.
Definition: Time.h:85