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
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index a1fea22..507507b 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -10,6 +10,7 @@
#include "Benchmark.h"
#include "CrashHandler.h"
#include "GMBench.h"
+#include "ProcStats.h"
#include "ResultsWriter.h"
#include "SKPBench.h"
#include "Stats.h"
@@ -590,7 +591,7 @@
} else if (FLAGS_quiet) {
SkDebugf("median\tbench\tconfig\n");
} else {
- SkDebugf("loops\tmin\tmedian\tmean\tmax\tstddev\tsamples\tconfig\tbench\n");
+ SkDebugf("maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\tsamples\tconfig\tbench\n");
}
SkTDArray<Config> configs;
@@ -673,7 +674,8 @@
SkDebugf("%s\t%s\t%s\n", HUMANIZE(stats.median), bench->getName(), config);
} else {
const double stddev_percent = 100 * sqrt(stats.var) / stats.mean;
- SkDebugf("%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n"
+ SkDebugf("%4dM\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n"
+ , sk_tools::getMaxResidentSetSizeMB()
, loops
, HUMANIZE(stats.min)
, HUMANIZE(stats.median)
diff --git a/dm/DMReporter.cpp b/dm/DMReporter.cpp
index 12bcfac..7b2cea8 100644
--- a/dm/DMReporter.cpp
+++ b/dm/DMReporter.cpp
@@ -22,9 +22,9 @@
status.appendf(", %d failed", failed);
}
if (FLAGS_verbose) {
- int max_rss_kb = sk_tools::getMaxResidentSetSizeKB();
- if (max_rss_kb >= 0) {
- status.appendf("\t%4dM peak", max_rss_kb / 1024);
+ int max_rss_mb = sk_tools::getMaxResidentSetSizeMB();
+ if (max_rss_mb >= 0) {
+ status.appendf("\t%4dM peak", max_rss_mb);
}
status.appendf("\t%5dms\t%s", timeMs, name.c_str());
}
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 7f012bc..674cab9 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -18,6 +18,7 @@
#include "gm_expectations.h"
#include "system_preferences.h"
#include "CrashHandler.h"
+#include "ProcStats.h"
#include "Resources.h"
#include "SamplePipeControllers.h"
#include "SkBitmap.h"
@@ -2386,10 +2387,11 @@
gmsRun++;
SkISize size = gm->getISize();
- SkDebugf("%sdrawing... %s [%d %d]\n", moduloStr.c_str(), shortName,
+ SkDebugf("%4dM %sdrawing... %s [%d %d]\n",
+ sk_tools::getMaxResidentSetSizeMB(), moduloStr.c_str(), shortName,
size.width(), size.height());
if (!FLAGS_dryRun)
- run_multiple_configs(gmmain, gm, configs, pdfRasterizers, tileGridReplayScales,
+ run_multiple_configs(gmmain, gm, configs, pdfRasterizers, tileGridReplayScales,
grFactory, gpuAPI);
}
diff --git a/gyp/bench.gyp b/gyp/bench.gyp
index 398700f..d53e0f7 100644
--- a/gyp/bench.gyp
+++ b/gyp/bench.gyp
@@ -24,6 +24,7 @@
'jsoncpp.gyp:jsoncpp',
'skia_lib.gyp:skia_lib',
'tools.gyp:crash_handler',
+ 'tools.gyp:proc_stats',
'tools.gyp:timer',
],
},
diff --git a/gyp/dm.gypi b/gyp/dm.gypi
index 238c153..1ecccd8 100644
--- a/gyp/dm.gypi
+++ b/gyp/dm.gypi
@@ -19,7 +19,7 @@
'jsoncpp.gyp:jsoncpp',
'skia_lib.gyp:skia_lib',
'tools.gyp:crash_handler',
- 'tools.gyp:sk_tool_proc_stats',
+ 'tools.gyp:proc_stats',
'tools.gyp:sk_tool_utils',
],
'includes': [
diff --git a/gyp/gm.gyp b/gyp/gm.gyp
index a11fde5..658a067 100644
--- a/gyp/gm.gyp
+++ b/gyp/gm.gyp
@@ -33,6 +33,7 @@
'skia_lib.gyp:skia_lib',
'tools.gyp:crash_handler',
'tools.gyp:gm_expectations',
+ 'tools.gyp:proc_stats',
'tools.gyp:resources',
'tools.gyp:sk_tool_utils',
],
diff --git a/gyp/tools.gyp b/gyp/tools.gyp
index 1766a09..d02aaca 100644
--- a/gyp/tools.gyp
+++ b/gyp/tools.gyp
@@ -530,7 +530,7 @@
'pdf.gyp:pdf',
'skia_lib.gyp:skia_lib',
'tools.gyp:picture_utils',
- 'tools.gyp:sk_tool_proc_stats',
+ 'tools.gyp:proc_stats',
],
'conditions': [
['skia_win_debuggers_path and skia_os == "win"',
@@ -648,7 +648,7 @@
],
},
{
- 'target_name': 'sk_tool_proc_stats',
+ 'target_name': 'proc_stats',
'type': 'static_library',
'sources': [
'../tools/ProcStats.h',
diff --git a/tools/ProcStats.cpp b/tools/ProcStats.cpp
index 9466039..eaa1379 100644
--- a/tools/ProcStats.cpp
+++ b/tools/ProcStats.cpp
@@ -12,19 +12,19 @@
defined(SK_BUILD_FOR_ANDROID)
#include <sys/resource.h>
- int sk_tools::getMaxResidentSetSizeKB() {
+ 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); // Darwin reports bytes.
+ return static_cast<int>(ru.ru_maxrss / 1024 / 1024); // Darwin reports bytes.
#else
- return static_cast<int>(ru.ru_maxrss); // Linux reports kilobytes.
+ return static_cast<int>(ru.ru_maxrss / 1024); // Linux reports kilobytes.
#endif
}
#else
- int sk_tools::getMaxResidentSetSizeKB() {
+ int sk_tools::getMaxResidentSetSizeMB() {
return -1;
}
diff --git a/tools/ProcStats.h b/tools/ProcStats.h
index 42849f1..14b98b7 100644
--- a/tools/ProcStats.h
+++ b/tools/ProcStats.h
@@ -18,7 +18,7 @@
* If not implemented for this OS, returns -1. Otherwise, return
* the maximum resident set size, as reported by getrusage().
*/
-int getMaxResidentSetSizeKB();
+int getMaxResidentSetSizeMB();
} // namespace sk_tools
diff --git a/tools/render_pdfs_main.cpp b/tools/render_pdfs_main.cpp
index a1bd62d..8e791d9 100644
--- a/tools/render_pdfs_main.cpp
+++ b/tools/render_pdfs_main.cpp
@@ -268,9 +268,9 @@
++failures;
}
- int max_rss_kb = sk_tools::getMaxResidentSetSizeKB();
- if (max_rss_kb >= 0) {
- SkDebugf(" %4dM peak rss", max_rss_kb / 1024);
+ int max_rss_mb = sk_tools::getMaxResidentSetSizeMB();
+ if (max_rss_mb >= 0) {
+ SkDebugf(" %4dM peak rss", max_rss_mb);
}
SkDebugf("\n");