Print max memory usage on Linux.
This is meant to help debug http://skbug.com/2793 BUG=skia:2793 R=halcanary@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/433403005
This commit is contained in:
parent
2069e22003
commit
4e212e8da7
@ -4,6 +4,17 @@
|
||||
#include "SkCommonFlags.h"
|
||||
#include "OverwriteLine.h"
|
||||
|
||||
#ifdef SK_BUILD_FOR_UNIX
|
||||
#include <sys/resource.h>
|
||||
static long get_max_rss_kb() {
|
||||
struct rusage ru;
|
||||
getrusage(RUSAGE_SELF, &ru);
|
||||
return ru.ru_maxrss;
|
||||
}
|
||||
#else
|
||||
static long get_max_rss_kb() { return 0; }
|
||||
#endif
|
||||
|
||||
namespace DM {
|
||||
|
||||
void Reporter::printStatus(SkString name, SkMSec timeMs) const {
|
||||
@ -21,7 +32,10 @@ void Reporter::printStatus(SkString name, SkMSec timeMs) const {
|
||||
status.appendf(", %d failed", failed);
|
||||
}
|
||||
if (FLAGS_verbose) {
|
||||
status.appendf("\t%5dms %s", timeMs, name.c_str());
|
||||
if (long max_rss_kb = get_max_rss_kb()) {
|
||||
status.appendf("\t%4ldM peak", max_rss_kb / 1024);
|
||||
}
|
||||
status.appendf("\t%5dms\t%s", timeMs, name.c_str());
|
||||
}
|
||||
SkDebugf("%s", status.c_str());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user