Skip to content

Commit 2cf5bbd

Browse files
authored
[onnxruntime_perf_test] Fix Mac peak working set size value (#27302)
### Description <!-- Describe your changes. --> On Mac, `ru_maxrss` is in bytes and on other platforms, it is in kilobytes. This change sets a different multiplier value when `defined(__APPLE__)`. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> Fix peak working set size reporting on Mac.
1 parent 5a9877a commit 2cf5bbd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

onnxruntime/test/perftest/posix/utils.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ namespace utils {
1717
std::size_t GetPeakWorkingSetSize() {
1818
struct rusage rusage;
1919
getrusage(RUSAGE_SELF, &rusage);
20-
return static_cast<size_t>(rusage.ru_maxrss * 1024L);
20+
21+
#if defined(__APPLE__)
22+
constexpr size_t kBytesPerMaxRssUnit = 1;
23+
#else
24+
constexpr size_t kBytesPerMaxRssUnit = 1024;
25+
#endif
26+
27+
return static_cast<size_t>(rusage.ru_maxrss) * kBytesPerMaxRssUnit;
2128
}
2229

2330
class CPUUsage : public ICPUUsage {

0 commit comments

Comments
 (0)