diff options
author | nga <nga@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
commit | 1f553f46fb4f3c5eec631352cdd900a0709016af (patch) | |
tree | a231fba2c03b440becaea6c86a2702d0bfb0336e /util/system/rusage.cpp | |
parent | c4de7efdedc25b49cbea74bd589eecb61b55b60a (diff) | |
download | ydb-1f553f46fb4f3c5eec631352cdd900a0709016af.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/rusage.cpp')
-rw-r--r-- | util/system/rusage.cpp | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/util/system/rusage.cpp b/util/system/rusage.cpp index 2befeca875..918169ebdf 100644 --- a/util/system/rusage.cpp +++ b/util/system/rusage.cpp @@ -1,40 +1,40 @@ #include "platform.h" - + #if defined(__APPLE__) && defined(__MACH__) #include <mach/mach.h> #endif -#ifdef _win_ - +#ifdef _win_ + #include "winint.h" #include <psapi.h> - -#else - + +#else + #include <sys/time.h> #include <sys/resource.h> - -#endif - -#include <util/generic/yexception.h> - -#include "info.h" - -#include "rusage.h" - -#ifdef _win_ -TDuration FiletimeToDuration(const FILETIME& ft) { + +#endif + +#include <util/generic/yexception.h> + +#include "info.h" + +#include "rusage.h" + +#ifdef _win_ +TDuration FiletimeToDuration(const FILETIME& ft) { union { ui64 ft_scalar; FILETIME ft_struct; } nt_time; - nt_time.ft_struct = ft; - return TDuration::MicroSeconds(nt_time.ft_scalar / 10); -} -#endif - + nt_time.ft_struct = ft; + return TDuration::MicroSeconds(nt_time.ft_scalar / 10); +} +#endif + size_t TRusage::GetCurrentRSS() { /* * Author: David Robert Nadeau @@ -74,40 +74,40 @@ size_t TRusage::GetCurrentRSS() { #endif } -void TRusage::Fill() { - *this = TRusage(); - -#ifdef _win_ - // copy-paste from PostgreSQL getrusage.c - - FILETIME starttime; - FILETIME exittime; - FILETIME kerneltime; - FILETIME usertime; - - if (GetProcessTimes(GetCurrentProcess(), &starttime, &exittime, &kerneltime, &usertime) == 0) { - ythrow TSystemError() << "GetProcessTimes failed"; - } - - Utime = FiletimeToDuration(usertime); - Stime = FiletimeToDuration(kerneltime); - - PROCESS_MEMORY_COUNTERS pmc; - - if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)) == 0) { - ythrow TSystemError() << "GetProcessMemoryInfo failed"; - } - +void TRusage::Fill() { + *this = TRusage(); + +#ifdef _win_ + // copy-paste from PostgreSQL getrusage.c + + FILETIME starttime; + FILETIME exittime; + FILETIME kerneltime; + FILETIME usertime; + + if (GetProcessTimes(GetCurrentProcess(), &starttime, &exittime, &kerneltime, &usertime) == 0) { + ythrow TSystemError() << "GetProcessTimes failed"; + } + + Utime = FiletimeToDuration(usertime); + Stime = FiletimeToDuration(kerneltime); + + PROCESS_MEMORY_COUNTERS pmc; + + if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)) == 0) { + ythrow TSystemError() << "GetProcessMemoryInfo failed"; + } + MaxRss = pmc.PeakWorkingSetSize; MajorPageFaults = pmc.PageFaultCount; - -#else - struct rusage ru; - int r = getrusage(RUSAGE_SELF, &ru); - if (r < 0) { - ythrow TSystemError() << "rusage failed"; - } - + +#else + struct rusage ru; + int r = getrusage(RUSAGE_SELF, &ru); + if (r < 0) { + ythrow TSystemError() << "rusage failed"; + } + #if defined(_darwin_) // see https://lists.apple.com/archives/darwin-kernel/2009/Mar/msg00005.html MaxRss = ru.ru_maxrss; @@ -115,7 +115,7 @@ void TRusage::Fill() { MaxRss = ru.ru_maxrss * 1024LL; #endif MajorPageFaults = ru.ru_majflt; - Utime = ru.ru_utime; - Stime = ru.ru_stime; -#endif -} + Utime = ru.ru_utime; + Stime = ru.ru_stime; +#endif +} |