skia2/tools/ProcStats.cpp
mtklein afb4379dbc Print max RSS in GM and nanobench too.
Everyone used MB, so update the API to just return that.

BUG=skia:
R=halcanary@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/483323002
2014-08-19 15:55:55 -07:00

32 lines
732 B
C++

/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "ProcStats.h"
#if defined(SK_BUILD_FOR_UNIX) || \
defined(SK_BUILD_FOR_MAC) || \
defined(SK_BUILD_FOR_ANDROID)
#include <sys/resource.h>
int sk_tools::getMaxResidentSetSizeMB() {
struct rusage ru;
getrusage(RUSAGE_SELF, &ru);
#if defined(SK_BUILD_FOR_MAC)
return static_cast<int>(ru.ru_maxrss / 1024 / 1024); // Darwin reports bytes.
#else
return static_cast<int>(ru.ru_maxrss / 1024); // Linux reports kilobytes.
#endif
}
#else
int sk_tools::getMaxResidentSetSizeMB() {
return -1;
}
#endif