diff options
author | halcanary <halcanary@google.com> | 2014-08-07 13:13:54 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-07 13:13:54 -0700 |
commit | 6274baae7fe82ce6481da367687aa6168356e1e1 (patch) | |
tree | fec4af39d1a812d0d28be4fb7d982845ca3c1948 /tools/ProcStats.cpp | |
parent | 0898e2b420fd497bbb85e9546b80453c77c45a6b (diff) |
Process Statistics header, add max RSS to render_pdfs
R=mtklein@google.com
Author: halcanary@google.com
Review URL: https://codereview.chromium.org/448993003
Diffstat (limited to 'tools/ProcStats.cpp')
-rw-r--r-- | tools/ProcStats.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/ProcStats.cpp b/tools/ProcStats.cpp new file mode 100644 index 0000000000..94660394f8 --- /dev/null +++ b/tools/ProcStats.cpp @@ -0,0 +1,31 @@ +/* + * 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::getMaxResidentSetSizeKB() { + struct rusage ru; + getrusage(RUSAGE_SELF, &ru); + #if defined(SK_BUILD_FOR_MAC) + return static_cast<int>(ru.ru_maxrss / 1024); // Darwin reports bytes. + #else + return static_cast<int>(ru.ru_maxrss); // Linux reports kilobytes. + #endif + } + +#else + + int sk_tools::getMaxResidentSetSizeKB() { + return -1; + } + +#endif |