MCPcopy Create free account
hub / github.com/catboost/catboost / Fill

Method Fill

util/system/rusage.cpp:75–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75void TRusage::Fill() {
76 *this = TRusage();
77
78#ifdef _win_
79 // copy-paste from PostgreSQL getrusage.c
80
81 FILETIME starttime;
82 FILETIME exittime;
83 FILETIME kerneltime;
84 FILETIME usertime;
85
86 if (GetProcessTimes(GetCurrentProcess(), &starttime, &exittime, &kerneltime, &usertime) == 0) {
87 ythrow TSystemError() << "GetProcessTimes failed";
88 }
89
90 Utime = FiletimeToDuration(usertime);
91 Stime = FiletimeToDuration(kerneltime);
92
93 PROCESS_MEMORY_COUNTERS pmc;
94
95 if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)) == 0) {
96 ythrow TSystemError() << "GetProcessMemoryInfo failed";
97 }
98
99 MaxRss = pmc.PeakWorkingSetSize;
100 MajorPageFaults = pmc.PageFaultCount;
101
102#else
103 struct rusage ru;
104 int r = getrusage(RUSAGE_SELF, &ru);
105 if (r < 0) {
106 ythrow TSystemError() << "rusage failed";
107 }
108
109 #if defined(_darwin_)
110 // see https://lists.apple.com/archives/darwin-kernel/2009/Mar/msg00005.html
111 MaxRss = ru.ru_maxrss;
112 #else
113 MaxRss = ru.ru_maxrss * 1024LL;
114 #endif
115 MajorPageFaults = ru.ru_majflt;
116 Utime = ru.ru_utime;
117 Stime = ru.ru_stime;
118#endif
119}

Callers 3

DoRecurseMethod · 0.45
Y_UNIT_TESTFunction · 0.45
GetMethod · 0.45

Calls 2

TRusageClass · 0.85
FiletimeToDurationFunction · 0.85

Tested by

no test coverage detected