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

Side by Side Diff: content/browser/memory/swap_metrics_observer_linux.cc

Issue 2824133002: Record swap metrics (Closed)
Patch Set: Created 3 years, 8 months 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/memory/swap_metrics_observer_linux.h"
6
7 #include "base/metrics/histogram_macros.h"
8 #include "base/process/process_metrics.h"
9
10 namespace content {
11
12 // static
13 SwapMetricsObserver* SwapMetricsObserver::GetInstance() {
14 return SwapMetricsObserverLinux::GetInstance();
15 }
16
17 // static
18 SwapMetricsObserverLinux* SwapMetricsObserverLinux::GetInstance() {
19 return base::Singleton<
Primiano Tucci (use gerrit) 2017/04/27 10:01:20 IWYU (+base/singleton.h). BTW these days you can j
bashi 2017/04/28 02:05:35 Changed to use static local. Thanks for the info!
20 SwapMetricsObserverLinux,
21 base::LeakySingletonTraits<SwapMetricsObserverLinux>>::get();
22 }
23
24 SwapMetricsObserverLinux::SwapMetricsObserverLinux() {}
25
26 SwapMetricsObserverLinux::~SwapMetricsObserverLinux() {}
27
28 void SwapMetricsObserverLinux::UpdateMetricsInternal(base::TimeDelta interval) {
29 base::SystemMemoryInfoKB memory_info;
30 if (!base::GetSystemMemoryInfo(&memory_info))
31 return;
32
33 // Don't record metrics when the system doesn't seem to have swap.
34 if (memory_info.pswpin == 0)
35 return;
Primiano Tucci (use gerrit) 2017/04/27 10:01:20 maybe also stop the timer in these failure cases?
bashi 2017/04/28 02:05:35 Yes. Probably we shouldn't start the timer in the
36
37 double in_counts = memory_info.pswpin - last_pswpin_;
38 double out_counts = memory_info.pswpout - last_pswpout_;
39 last_pswpin_ = memory_info.pswpin;
40 last_pswpout_ = memory_info.pswpout;
41
42 if (interval.is_zero())
43 return;
44
45 UMA_HISTOGRAM_COUNTS_10000("Memory.Experimental.SwapInPerSecond",
46 in_counts / interval.InSecondsF());
47 UMA_HISTOGRAM_COUNTS_10000("Memory.Experimental.SwapOutPerSecond",
48 out_counts / interval.InSecondsF());
49 }
50
51 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698