24 #include <condition_variable>
35 #include <sys/resource.h>
44 class ProfileEventSingleton {
71 database, txt.c_str(), std::chrono::duration_cast<microseconds>(
now().time_since_epoch()));
77 microseconds start_ms = std::chrono::duration_cast<microseconds>(start.time_since_epoch());
78 microseconds end_ms = std::chrono::duration_cast<microseconds>(end.time_since_epoch());
91 microseconds
time = std::chrono::duration_cast<microseconds>(
now().time_since_epoch());
94 HANDLE hProcess = GetCurrentProcess();
95 FILETIME systemFileTime, userFileTime;
96 GetProcessTimes(hProcess,
nullptr,
nullptr, &systemFileTime, &userFileTime);
101 uint64_t systemTime = systemFileTime.dwHighDateTime;
102 systemTime = (systemTime << 32) | systemFileTime.dwLowDateTime;
105 uint64_t userTime = userFileTime.dwHighDateTime;
106 userTime = (userTime << 32) | userFileTime.dwLowDateTime;
108 PROCESS_MEMORY_COUNTERS processMemoryCounters;
109 GetProcessMemoryInfo(hProcess, &processMemoryCounters,
sizeof(processMemoryCounters));
111 size_t maxRSS = processMemoryCounters.PeakWorkingSetSize / 1000;
115 getrusage(RUSAGE_SELF, &ru);
117 uint64_t systemTime = ru.ru_stime.tv_sec * 1000000 + ru.ru_stime.tv_usec;
119 uint64_t userTime = ru.ru_utime.tv_sec * 1000000 + ru.ru_utime.tv_usec;
121 size_t maxRSS = ru.ru_maxrss;
125 database, txt.c_str(),
time, systemTime, userTime, maxRSS);
136 std::cerr <<
"Cannot open profile log file <" +
filename +
">";
156 const profile::ProfileDatabase&
getDB()
const {
161 database = profile::ProfileDatabase(databaseFilename);
217 th = std::thread([
this]() {