summaryrefslogtreecommitdiffstats
path: root/base/process
diff options
context:
space:
mode:
authorjwmak@chromium.org <jwmak@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-22 01:12:19 +0000
committerjwmak@chromium.org <jwmak@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-22 01:12:19 +0000
commit14b4f10796baaf95226ed6395278f2bdf4803b34 (patch)
treecd3f623b6827ee04a2ebdd1b15d11e45c9af29d9 /base/process
parent5e3aa80300e54bafc3d59fb8e84cf0c1bfea30f1 (diff)
downloadchromium_src-14b4f10796baaf95226ed6395278f2bdf4803b34.zip
chromium_src-14b4f10796baaf95226ed6395278f2bdf4803b34.tar.gz
chromium_src-14b4f10796baaf95226ed6395278f2bdf4803b34.tar.bz2
process_metrics.h provides a variety of platform specific functions for getting performance metrics for the the system, but the metrics that are available from system to system requires unwinding all the ifdefs in the file. This patch introduces a base class that contains all the system-wide performance metrics available for the particular platform. In perfmon applications, one often just wants to grab all the metrics that we have for the system and dump them. In followup patches, an Value* AsValue() will be added to this class to facilitate this use case.
BUG=236763 Review URL: https://chromiumcodereview.appspot.com/22433005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218889 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process')
-rw-r--r--base/process/process_metrics.cc22
-rw-r--r--base/process/process_metrics.h16
2 files changed, 38 insertions, 0 deletions
diff --git a/base/process/process_metrics.cc b/base/process/process_metrics.cc
new file mode 100644
index 0000000..9ba3fb4
--- /dev/null
+++ b/base/process/process_metrics.cc
@@ -0,0 +1,22 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/process/process_metrics.h"
+
+#include "base/values.h"
+
+namespace base {
+
+SystemMetrics SystemMetrics::Sample() {
+ SystemMetrics system_metrics;
+
+ system_metrics.committed_memory_ = GetSystemCommitCharge();
+#if defined(OS_LINUX) || defined(OS_ANDROID)
+ GetSystemMemoryInfo(&system_metrics.memory_info_);
+#endif
+
+ return system_metrics;
+}
+
+} // namespace base
diff --git a/base/process/process_metrics.h b/base/process/process_metrics.h
index e329b4e..c1b462a 100644
--- a/base/process/process_metrics.h
+++ b/base/process/process_metrics.h
@@ -264,6 +264,22 @@ BASE_EXPORT extern const char kProcSelfExe[];
size_t GetMaxFds();
#endif // defined(OS_POSIX)
+// Collects and holds performance metrics for system memory and disk.
+// Provides functionality to retrieve the data on various platforms and
+// to serialize the stored data.
+class SystemMetrics {
+ public:
+ SystemMetrics() : committed_memory_(0) { }
+
+ static SystemMetrics Sample();
+
+ private:
+ size_t committed_memory_;
+#if defined(OS_LINUX) || defined(OS_ANDROID)
+ SystemMemoryInfoKB memory_info_;
+#endif
+};
+
} // namespace base
#endif // BASE_PROCESS_PROCESS_METRICS_H_