QMCPACK
sysutil.h File Reference
+ Include dependency graph for sysutil.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::string getHostName ()
 < return the host name More...
 
std::string getDateAndTime ()
 
std::string getDateAndTime (const char *format)
 get the time and date with a format More...
 
size_t freemem ()
 
size_t memusage ()
 

Detailed Description

Function declarations to get system information.

Definition in file sysutil.h.

Function Documentation

◆ freemem()

size_t freemem ( )

Definition at line 53 of file sysutil.cpp.

Referenced by qmcplusplus::print_mem().

54 {
55 #ifdef __linux__
56  struct sysinfo si;
57  sysinfo(&si);
58  si.freeram += si.bufferram;
59  return si.freeram;
60 #else
61  return 0;
62 #endif
63 }

◆ getDateAndTime() [1/2]

std::string getDateAndTime ( )

Definition at line 31 of file sysutil.cpp.

Referenced by ProjectData::get(), ProjectData::ProjectData(), ProjectData::put(), and VariableSet::writeToHDF().

32 {
33  time_t now;
34  time(&now);
35  return ctime(&now);
36 }

◆ getDateAndTime() [2/2]

std::string getDateAndTime ( const char *  format)

get the time and date with a format

Definition at line 38 of file sysutil.cpp.

39 {
40  time_t now;
41  time(&now);
42  tm* now_c = localtime(&now);
43  char d[32];
44  strftime(d, 32, format, now_c);
45  return std::string(d);
46 }

◆ getHostName()

std::string getHostName ( )

< return the host name

return the date and time

Definition at line 24 of file sysutil.cpp.

Referenced by ProjectData::put().

25 {
26  utsname mysys;
27  uname(&mysys);
28  return std::string(mysys.nodename);
29 }

◆ memusage()

size_t memusage ( )

Definition at line 66 of file sysutil.cpp.

Referenced by qmcplusplus::print_mem().

67 {
68 #ifdef __linux__
69  struct rusage RU; /* heap memory usage */
70  getrusage(RUSAGE_SELF, &RU);
71  return RU.ru_maxrss;
72 #else
73  return 0;
74 #endif
75 }