From 24b8a8cd1af07fd8a6cf8ae125e287f6aa73a2da Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Thu, 9 Jul 2020 10:04:33 -0400 Subject: [PATCH] Switch back to mallinfo in SkSL memory benchmark Early results from measuring RSS (via /proc or similar) shows results that aren't very accurate or stable. From previous detailed testing, I know that mallinfo gives a good answer. We only really need results from ~one machine, so limiting to UNIX bots isn't a big deal. Change-Id: I73af043720b1204e1da436e2e63b19766a97a9a2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301445 Reviewed-by: Mike Klein Commit-Queue: Brian Osman --- bench/SkSLBench.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/bench/SkSLBench.cpp b/bench/SkSLBench.cpp index 97b9af2899..4175e395fc 100644 --- a/bench/SkSLBench.cpp +++ b/bench/SkSLBench.cpp @@ -8,7 +8,6 @@ #include "bench/ResultsWriter.h" #include "bench/SkSLBench.h" #include "src/sksl/SkSLCompiler.h" -#include "tools/ProcStats.h" class SkSLBench : public Benchmark { public: @@ -119,23 +118,32 @@ DEF_BENCH(return new SkSLBench("huge", R"( } )"); ) +#if defined(SK_BUILD_FOR_UNIX) + +#include + // These benchmarks aren't timed, they produce memory usage statistics. They run standalone, and // directly add their results to the nanobench log. void RunSkSLMemoryBenchmarks(NanoJSONResultsWriter* log) { - auto bench = [log](const char* name, int64_t bytes) { + auto heap_bytes_used = []() { return mallinfo().uordblks; }; + auto bench = [log](const char* name, int bytes) { log->beginObject(name); // test log->beginObject("meta"); // config - log->appendS64("bytes", bytes); // sub_result + log->appendS32("bytes", bytes); // sub_result log->endObject(); // config log->endObject(); // test }; { - int64_t before = sk_tools::getCurrResidentSetSizeBytes(); + int before = heap_bytes_used(); SkSL::Compiler compiler; - int64_t after = sk_tools::getCurrResidentSetSizeBytes(); - if (before > 0 && after > 0) { - bench("sksl_compiler_baseline", after - before); - } + int after = heap_bytes_used(); + bench("sksl_compiler_baseline", after - before); } } + +#else + +void RunSkSLMemoryBenchmarks(NanoJSONResultsWriter*) {} + +#endif