37 #include "ompl/tools/benchmark/MachineSpecs.h"
54 PROCESS_MEMORY_COUNTERS pmc;
56 hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
59 GetCurrentProcessId() );
65 if ( GetProcessMemoryInfo( hProcess, &pmc,
sizeof(pmc)) )
66 result = pmc.WorkingSetSize;
67 CloseHandle( hProcess );
73 std::string getCPUInfoAux()
75 static const int BUF_SIZE = 256;
76 char buffer[BUF_SIZE];
77 std::stringstream result;
78 FILE *cmdPipe = _popen(
"wmic cpu list full",
"rt");
81 while (fgets(buffer, BUF_SIZE, cmdPipe))
94 #include <mach/mach_init.h>
95 #include <mach/task.h>
97 #include <sys/resource.h>
105 task_basic_info info;
106 kern_return_t rval = 0;
107 mach_port_t task = mach_task_self();
108 mach_msg_type_number_t tcnt = TASK_BASIC_INFO_COUNT;
109 task_info_t tptr = (task_info_t) &info;
111 memset(&info, 0,
sizeof(info));
113 rval = task_info(task, TASK_BASIC_INFO, tptr, &tcnt);
114 if (!(rval == KERN_SUCCESS))
return 0;
115 return info.resident_size;
118 std::string getCPUInfoAux()
120 static const int BUF_SIZE = 256;
121 char buffer[BUF_SIZE];
122 std::stringstream result;
123 FILE *cmdPipe = popen(
"sysctl hw",
"r");
126 while (fgets(buffer, BUF_SIZE, cmdPipe))
135 #if defined _POSIX_VERSION || defined _POSIX2_VERSION || defined __linux__
151 ifstream stat_stream(
"/proc/self/stat",ios_base::in);
153 if (stat_stream.good() && !stat_stream.eof())
157 string pid, comm, state, ppid, pgrp, session, tty_nr;
158 string tpgid, flags, minflt, cminflt, majflt, cmajflt;
159 string utime, stime, cutime, cstime, priority, nice;
160 string O, itrealvalue, starttime;
168 stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr
169 >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt
170 >> utime >> stime >> cutime >> cstime >> priority >> nice
171 >> O >> itrealvalue >> starttime >> vsize >> rss;
174 return rss * page_size;
179 std::string getCPUInfoAux()
181 static const int BUF_SIZE = 4096;
182 char buffer[BUF_SIZE];
183 std::stringstream result;
184 FILE *cmdPipe = popen(
"lscpu",
"r");
187 while (fgets(buffer, BUF_SIZE, cmdPipe))
202 std::string getCPUInfoAux()
204 return std::string();
213 MemUsage_t result = getProcessMemoryUsageAux();
223 std::string result = getCPUInfoAux();
224 if (result.size() == 0)
226 OMPL_WARN(
"Unable to get CPU information");
233 static const int BUF_SIZE = 1024;
234 char buffer[BUF_SIZE];
235 int len = gethostname(buffer,
sizeof(buffer));
237 return std::string();
240 buffer[BUF_SIZE - 1] =
'\0';
241 return std::string(buffer);
std::string getCPUInfo()
Get information about the CPU of the machine in use.
#define OMPL_WARN(fmt,...)
Log a formatted warning string.
MemUsage_t getProcessMemoryUsage()
Get the amount of memory the current process is using. This should work on major platforms (Windows...
unsigned long long MemUsage_t
Amount of memory used, in bytes.
std::string getHostname()
Get the hostname of the machine in use.