Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3719)

Unified Diff: chromeos/device_event_log.cc

Issue 811623002: Add logging for slow device events, limit network UI update rate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch_441650
Patch Set: Rebase, self review Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/device_event_log.cc
diff --git a/chromeos/device_event_log.cc b/chromeos/device_event_log.cc
index 8251e7d579e80e4a8fbe83656e07942f91a44419..5a5acee805f37e53e0f2ccd1b9bd8e1ac889f3f8 100644
--- a/chromeos/device_event_log.cc
+++ b/chromeos/device_event_log.cc
@@ -17,6 +17,9 @@ namespace {
const size_t kDefaultMaxEntries = 4000;
+const int kSlowMethodThresholdMs = 10;
+const int kVerySlowMethodThresholdMs = 50;
+
DeviceEventLogImpl* g_device_event_log = NULL;
} // namespace
@@ -83,6 +86,23 @@ DeviceEventLogInstance::~DeviceEventLogInstance() {
device_event_log::AddEntry(file_, line_, type_, level_, stream_.str());
}
+DeviceLogIfSlow::DeviceLogIfSlow(LogType type,
+ const char* file,
+ const std::string& name)
+ : file_(file), type_(type), name_(name) {
+}
+
+DeviceLogIfSlow::~DeviceLogIfSlow() {
+ if (timer_.Elapsed().InMilliseconds() >= kSlowMethodThresholdMs) {
+ LogLevel level(LOG_LEVEL_DEBUG);
+ if (timer_.Elapsed().InMilliseconds() >= kVerySlowMethodThresholdMs)
+ level = LOG_LEVEL_ERROR;
+ DEVICE_LOG(type_, level) << "@@@ Slow method: " << file_ << ":" << name_
+ << ": " << timer_.Elapsed().InMilliseconds()
+ << "ms";
+ }
+}
+
} // namespace internal
} // namespace device_event_log

Powered by Google App Engine
This is Rietveld 408576698