Skip to content

Commit

Permalink
Reorder usage so mac is consistent
Browse files Browse the repository at this point in the history
And Linux makes sense
  • Loading branch information
kpu committed Dec 7, 2020
1 parent d575cb3 commit 4a27753
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions util/usage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,23 +197,23 @@ uint64_t RSSMax() {

void PrintUsage(std::ostream &out) {
#if !defined(_WIN32) && !defined(_WIN64)
#if defined(__MACH__) || defined(__APPLE__)
#if defined(__MACH__) || defined(__APPLE__)
struct mach_task_basic_info t_info;
char name[2 * MAXCOMLEN] = {0};

proc_name(getpid(), name, sizeof(name));
mach_msg_type_number_t t_info_count = MACH_TASK_BASIC_INFO_COUNT;
task_info(mach_task_self(), MACH_TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);

out << name << '\t';
out << t_info.resident_size_max << '\t';
out << t_info.resident_size << '\t';
out << name << '\t';
#else
#else
// Linux doesn't set memory usage in getrusage :-(
std::set<std::string> headers;
headers.insert("Name:");
headers.insert("VmPeak:");
headers.insert("VmRSS:");
headers.insert("Name:");

std::ifstream status("/proc/self/status", std::ios::in);
std::string header, value;
Expand All @@ -222,7 +222,7 @@ void PrintUsage(std::ostream &out) {
out << header << SkipSpaces(value.c_str()) << '\t';
}
}
#endif
#endif

struct rusage usage;
if (getrusage(RUSAGE_SELF, &usage)) {
Expand Down

0 comments on commit 4a27753

Please sign in to comment.