diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-19 10:21:09 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-03-19 10:21:09 +0000 |
commit | 82d5b7e868985d4cce68b9c6ce69de8c8b01470c (patch) | |
tree | bea6e0b0298dac162c00e21b551ed6fb5efc7ccd /staging_vespalib/src | |
parent | 8a073477b45ec34c4a614391d345637c502dc526 (diff) |
Avoid using slow std::string and std::ifstream, just use asciistream.
Diffstat (limited to 'staging_vespalib/src')
-rw-r--r-- | staging_vespalib/src/vespa/vespalib/util/process_memory_stats.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/util/process_memory_stats.cpp b/staging_vespalib/src/vespa/vespalib/util/process_memory_stats.cpp index 15626c6ff77..554dcf9a4fe 100644 --- a/staging_vespalib/src/vespa/vespalib/util/process_memory_stats.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/process_memory_stats.cpp @@ -2,8 +2,6 @@ #include "process_memory_stats.h" #include <vespa/vespalib/stllike/asciistream.h> -#include <fstream> -#include <sstream> #include <algorithm> #include <vespa/log/log.h> @@ -92,13 +90,12 @@ ProcessMemoryStats::createStatsFromSmaps() { ProcessMemoryStats ret; #ifdef __linux__ - std::ifstream smaps("/proc/self/smaps"); - std::string backedLine; + asciistream smaps = asciistream::createFromDevice("/proc/self/smaps"); bool anonymous = true; uint64_t lineVal = 0; - while (smaps.good()) { - std::getline(smaps, backedLine); - vespalib::stringref line(backedLine); + while (!smaps.eof()) { + string backedLine = smaps.getline(); + stringref line(backedLine); if (isRange(line)) { ret._mappings_count += 1; anonymous = isAnonymous(line); |