From edafa4dac036539566db0a5ff410a9ed4c51e1f5 Mon Sep 17 00:00:00 2001 From: Edward Chen <18449977+edgchen1@users.noreply.github.com> Date: Tue, 10 Feb 2026 10:07:31 -0800 Subject: [PATCH 1/2] [onnxruntime_perf_test] Fix Apple peak working set size value --- onnxruntime/test/perftest/posix/utils.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/onnxruntime/test/perftest/posix/utils.cc b/onnxruntime/test/perftest/posix/utils.cc index 9bf029d8dff35..185c3899e9d70 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 { From 6a79fc05b781f1fc6546321af7a1073b985cf468 Mon Sep 17 00:00:00 2001 From: Edward Chen <18449977+edgchen1@users.noreply.github.com> Date: Tue, 10 Feb 2026 10:10:06 -0800 Subject: [PATCH 2/2] update cast --- onnxruntime/test/perftest/posix/utils.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime/test/perftest/posix/utils.cc b/onnxruntime/test/perftest/posix/utils.cc index 185c3899e9d70..09d62c6f5d808 100644 --- a/onnxruntime/test/perftest/posix/utils.cc +++ b/onnxruntime/test/perftest/posix/utils.cc @@ -24,7 +24,7 @@ std::size_t GetPeakWorkingSetSize() { constexpr size_t kBytesPerMaxRssUnit = 1024; #endif - return static_cast(rusage.ru_maxrss * kBytesPerMaxRssUnit); + return static_cast(rusage.ru_maxrss) * kBytesPerMaxRssUnit; } class CPUUsage : public ICPUUsage {