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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/device_event_log.h" 5 #include "chromeos/device_event_log.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chromeos/device_event_log_impl.h" 10 #include "chromeos/device_event_log_impl.h"
11 11
12 namespace chromeos { 12 namespace chromeos {
13 13
14 namespace device_event_log { 14 namespace device_event_log {
15 15
16 namespace { 16 namespace {
17 17
18 const size_t kDefaultMaxEntries = 4000; 18 const size_t kDefaultMaxEntries = 4000;
19 19
20 const int kSlowMethodThresholdMs = 10;
21 const int kVerySlowMethodThresholdMs = 50;
22
20 DeviceEventLogImpl* g_device_event_log = NULL; 23 DeviceEventLogImpl* g_device_event_log = NULL;
21 24
22 } // namespace 25 } // namespace
23 26
24 const LogLevel kDefaultLogLevel = LOG_LEVEL_EVENT; 27 const LogLevel kDefaultLogLevel = LOG_LEVEL_EVENT;
25 28
26 void Initialize(size_t max_entries) { 29 void Initialize(size_t max_entries) {
27 CHECK(!g_device_event_log); 30 CHECK(!g_device_event_log);
28 if (max_entries == 0) 31 if (max_entries == 0)
29 max_entries = kDefaultMaxEntries; 32 max_entries = kDefaultMaxEntries;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 int line, 79 int line,
77 device_event_log::LogType type, 80 device_event_log::LogType type,
78 device_event_log::LogLevel level) 81 device_event_log::LogLevel level)
79 : file_(file), line_(line), type_(type), level_(level) { 82 : file_(file), line_(line), type_(type), level_(level) {
80 } 83 }
81 84
82 DeviceEventLogInstance::~DeviceEventLogInstance() { 85 DeviceEventLogInstance::~DeviceEventLogInstance() {
83 device_event_log::AddEntry(file_, line_, type_, level_, stream_.str()); 86 device_event_log::AddEntry(file_, line_, type_, level_, stream_.str());
84 } 87 }
85 88
89 ScopedDeviceLogIfSlow::ScopedDeviceLogIfSlow(LogType type,
90 const char* file,
91 const std::string& name)
92 : file_(file), type_(type), name_(name) {
93 }
94
95 ScopedDeviceLogIfSlow::~ScopedDeviceLogIfSlow() {
96 if (timer_.Elapsed().InMilliseconds() >= kSlowMethodThresholdMs) {
97 LogLevel level(LOG_LEVEL_DEBUG);
98 if (timer_.Elapsed().InMilliseconds() >= kVerySlowMethodThresholdMs)
99 level = LOG_LEVEL_ERROR;
100 DEVICE_LOG(type_, level) << "@@@ Slow method: " << file_ << ":" << name_
101 << ": " << timer_.Elapsed().InMilliseconds()
102 << "ms";
103 }
104 }
105
86 } // namespace internal 106 } // namespace internal
87 107
88 } // namespace device_event_log 108 } // namespace device_event_log
89 109
90 } // namespace chromeos 110 } // namespace chromeos
OLDNEW
« 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