diff options
Diffstat (limited to 'util/usage.cc')
-rw-r--r-- | util/usage.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/util/usage.cc b/util/usage.cc index 5f66b17d2..7965e9645 100644 --- a/util/usage.cc +++ b/util/usage.cc @@ -135,14 +135,26 @@ double WallTime() { return Subtract(GetWall(), kRecordStart.Started()); } -double UserTime() { -#if !defined(_WIN32) && !defined(_WIN64) +double CPUTime() { +#if defined(_WIN32) || defined(_WIN64) + return 0.0; +#else struct rusage usage; if (getrusage(RUSAGE_SELF, &usage)) return 0.0; - return DoubleSec(usage.ru_utime); + return DoubleSec(usage.ru_utime) + DoubleSec(usage.ru_stime); +#endif +} + +uint64_t RSSMax() { +#if defined(_WIN32) || defined(_WIN64) + return 0; +#else + struct rusage usage; + if (getrusage(RUSAGE_SELF, &usage)) + return 0; + return static_cast<uint64_t>(usage.ru_maxrss) * 1024; #endif - return 0.0; } void PrintUsage(std::ostream &out) { @@ -274,6 +286,7 @@ template <class Num> uint64_t ParseNum(const std::string &arg) { return static_cast<uint64_t>(static_cast<double>(value) * static_cast<double>(mem) / 100.0); } + if (after == "k") after == "K"; std::string units("bKMGTPEZY"); std::string::size_type index = units.find(after[0]); UTIL_THROW_IF_ARG(index == std::string::npos, SizeParseError, (arg), "the allowed suffixes are " << units << "%."); |