From a70d79e869e5a8dabf6bb25f5494695f1a502b9b Mon Sep 17 00:00:00 2001 From: flamingcow Date: Sat, 11 May 2019 21:55:53 -0700 Subject: [PATCH] Configurable title --- usage.cc | 8 ++++++-- usage.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/usage.cc b/usage.cc index 3acd725..5aae8ef 100644 --- a/usage.cc +++ b/usage.cc @@ -46,8 +46,12 @@ void UsageTracker::Stop() { invol_ctxt_sw_ += end_usage.ru_nivcsw - start_usage_.ru_nivcsw; } -void UsageTracker::Log() { - VLOG(1) << "usage:"; +void UsageTracker::Log(const std::string_view& title) { + if (!title.empty()) { + // Need to do this here so --vmodule works properly + VLOG(1) << title << ":"; + } + VLOG(1) << "\t events: " << std::setw(19) << std::setfill(' ') << events_; VLOG(1) << "\t wall time: " << std::setw(19) << std::setfill(' ') << wall_time_.count() << "ns"; VLOG(1) << "\t user time: " << std::setw(19) << std::setfill(' ') << user_time_.count() << "ns (" << ((user_time_ * 100) / (user_time_ + sys_time_)) << "%)"; diff --git a/usage.h b/usage.h index 9e659b4..db0892c 100644 --- a/usage.h +++ b/usage.h @@ -13,7 +13,7 @@ class UsageTracker { void Start(); void Stop(); - void Log(); + void Log(const std::string_view& title=""); private: bool running_ = false;