diff --git a/onnxruntime/test/perftest/posix/utils.cc b/onnxruntime/test/perftest/posix/utils.cc index 9bf029d8dff35..09d62c6f5d808 100644 --- a/onnxruntime/test/perftest/posix/utils.cc +++ b/onnxruntime/test/perftest/posix/utils.cc @@ -17,7 +17,14 @@ namespace utils { std::size_t GetPeakWorkingSetSize() { struct rusage rusage; getrusage(RUSAGE_SELF, &rusage); - return static_cast(rusage.ru_maxrss * 1024L); + +#if defined(__APPLE__) + constexpr size_t kBytesPerMaxRssUnit = 1; +#else + constexpr size_t kBytesPerMaxRssUnit = 1024; +#endif + + return static_cast(rusage.ru_maxrss) * kBytesPerMaxRssUnit; } class CPUUsage : public ICPUUsage {