OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "ProcStats.h" | 8 #include "ProcStats.h" |
| 9 #include "SkTypes.h" |
9 | 10 |
10 #if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_
FOR_IOS) || defined(SK_BUILD_FOR_ANDROID) | 11 #if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_
FOR_IOS) || defined(SK_BUILD_FOR_ANDROID) |
11 #include <sys/resource.h> | 12 #include <sys/resource.h> |
12 int sk_tools::getMaxResidentSetSizeMB() { | 13 int sk_tools::getMaxResidentSetSizeMB() { |
13 struct rusage ru; | 14 struct rusage ru; |
14 getrusage(RUSAGE_SELF, &ru); | 15 getrusage(RUSAGE_SELF, &ru); |
15 #if defined(SK_BUILD_FOR_MAC) | 16 #if defined(SK_BUILD_FOR_MAC) |
16 return static_cast<int>(ru.ru_maxrss / 1024 / 1024); // Darwin reports
bytes. | 17 return static_cast<int>(ru.ru_maxrss / 1024 / 1024); // Darwin reports
bytes. |
17 #else | 18 #else |
18 return static_cast<int>(ru.ru_maxrss / 1024); // Linux reports kilobyte
s. | 19 return static_cast<int>(ru.ru_maxrss / 1024); // Linux reports kilobyte
s. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 61 |
61 #elif defined(SK_BUILD_FOR_WIN32) | 62 #elif defined(SK_BUILD_FOR_WIN32) |
62 int sk_tools::getCurrResidentSetSizeMB() { | 63 int sk_tools::getCurrResidentSetSizeMB() { |
63 PROCESS_MEMORY_COUNTERS info; | 64 PROCESS_MEMORY_COUNTERS info; |
64 GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info)); | 65 GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info)); |
65 return static_cast<int>(info.WorkingSetSize / 1024 / 1024); // Windows
reports bytes. | 66 return static_cast<int>(info.WorkingSetSize / 1024 / 1024); // Windows
reports bytes. |
66 } | 67 } |
67 #else | 68 #else |
68 int sk_tools::getCurrResidentSetSizeMB() { return -1; } | 69 int sk_tools::getCurrResidentSetSizeMB() { return -1; } |
69 #endif | 70 #endif |
OLD | NEW |