37 #include "ompl/tools/benchmark/MachineSpecs.h"
54 PROCESS_MEMORY_COUNTERS pmc;
56 hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
false, GetCurrentProcessId());
60 if (
nullptr != hProcess)
62 if (GetProcessMemoryInfo(hProcess, &pmc,
sizeof(pmc)))
63 result = pmc.WorkingSetSize;
64 CloseHandle(hProcess);
70 std::string getCPUInfoAux()
72 static const int BUF_SIZE = 256;
73 char buffer[BUF_SIZE];
74 std::stringstream result;
75 FILE *cmdPipe = _popen(
"wmic cpu list full",
"rt");
76 if (cmdPipe !=
nullptr)
78 while (fgets(buffer, BUF_SIZE, cmdPipe))
90 #include <mach/mach_init.h>
91 #include <mach/task.h>
93 #include <sys/resource.h>
100 task_basic_info info;
101 kern_return_t rval = 0;
102 mach_port_t task = mach_task_self();
103 mach_msg_type_number_t tcnt = TASK_BASIC_INFO_COUNT;
104 auto tptr = (task_info_t)&info;
106 memset(&info, 0,
sizeof(info));
108 rval = task_info(task, TASK_BASIC_INFO, tptr, &tcnt);
109 if (!(rval == KERN_SUCCESS))
111 return info.resident_size;
114 std::string getCPUInfoAux()
116 static const int BUF_SIZE = 256;
117 char buffer[BUF_SIZE];
118 std::stringstream result;
119 FILE *cmdPipe = popen(
"sysctl hw",
"r");
120 if (cmdPipe !=
nullptr)
122 while (fgets(buffer, BUF_SIZE, cmdPipe))
132 #if defined _POSIX_VERSION || defined _POSIX2_VERSION || defined __linux__
147 ifstream stat_stream(
"/proc/self/stat", ios_base::in);
149 if (stat_stream.good() && !stat_stream.eof())
153 string pid, comm, state, ppid, pgrp, session, tty_nr;
154 string tpgid, flags, minflt, cminflt, majflt, cmajflt;
155 string utime, stime, cutime, cstime, priority, nice;
156 string O, itrealvalue, starttime;
163 stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr >> tpgid >> flags >> minflt >>
164 cminflt >> majflt >> cmajflt >> utime >> stime >> cutime >> cstime >> priority >> nice >> O >>
165 itrealvalue >> starttime >> vsize >> rss;
168 return rss * page_size;
173 std::string getCPUInfoAux()
175 static const int BUF_SIZE = 4096;
176 char buffer[BUF_SIZE];
177 std::stringstream result;
178 FILE *cmdPipe = popen(
"lscpu",
"r");
179 if (cmdPipe !=
nullptr)
181 while (fgets(buffer, BUF_SIZE, cmdPipe))
196 std::string getCPUInfoAux()
198 return std::string();
207 MemUsage_t result = getProcessMemoryUsageAux();
217 std::string result = getCPUInfoAux();
218 if (result.size() == 0)
220 OMPL_WARN(
"Unable to get CPU information");
227 static const int BUF_SIZE = 1024;
228 char buffer[BUF_SIZE];
229 int len = gethostname(buffer,
sizeof(buffer));
231 return std::string();
234 buffer[BUF_SIZE - 1] =
'\0';
235 return std::string(buffer);