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

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: Feedback 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
« no previous file with comments | « chromeos/device_event_log.h ('k') | chromeos/network/network_state_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/device_event_log.cc
diff --git a/chromeos/device_event_log.cc b/chromeos/device_event_log.cc
index 8251e7d579e80e4a8fbe83656e07942f91a44419..aaded58a3ebc8dd2c145ee462e29975ecf16f341 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());
}
+ScopedDeviceLogIfSlow::ScopedDeviceLogIfSlow(LogType type,
+ const char* file,
+ const std::string& name)
+ : file_(file), type_(type), name_(name) {
+}
+
+ScopedDeviceLogIfSlow::~ScopedDeviceLogIfSlow() {
+ 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
« no previous file with comments | « chromeos/device_event_log.h ('k') | chromeos/network/network_state_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698