summaryrefslogtreecommitdiffstats
path: root/chrome/test/perf
diff options
context:
space:
mode:
authorsgk@chromium.org <sgk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 06:57:28 +0000
committersgk@chromium.org <sgk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 06:57:28 +0000
commited26d948be84443236a8a165ac2a3ccf63c2e02a (patch)
treea41de5ad3954557cbf9a7b0e1bc61c923fc05269 /chrome/test/perf
parentad33fd4bdd8b7117e2644b34f553a2f14faea653 (diff)
downloadchromium_src-ed26d948be84443236a8a165ac2a3ccf63c2e02a.zip
chromium_src-ed26d948be84443236a8a165ac2a3ccf63c2e02a.tar.gz
chromium_src-ed26d948be84443236a8a165ac2a3ccf63c2e02a.tar.bz2
More memory stats code cleanup:
Move GetSystemCommitCharge() into bsae\process_util*. Kill PrintChromeMemoryUsageInfo(), which was only used by reliability_tests.exe on Windows and whose stats are obsolete. Delete the now-unnecessary chrome\test\perf\mem_usage* files. BUG=none TEST=none Review URL: http://codereview.chromium.org/371025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31423 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/perf')
-rw-r--r--chrome/test/perf/mem_usage.h17
-rw-r--r--chrome/test/perf/mem_usage_linux.cc60
-rw-r--r--chrome/test/perf/mem_usage_mac.cc37
-rw-r--r--chrome/test/perf/mem_usage_win.cc97
4 files changed, 0 insertions, 211 deletions
diff --git a/chrome/test/perf/mem_usage.h b/chrome/test/perf/mem_usage.h
deleted file mode 100644
index 90a4824..0000000
--- a/chrome/test/perf/mem_usage.h
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) 2006-2008 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.
-
-#ifndef CHROME_TEST_PERF_MEM_USAGE_H_
-#define CHROME_TEST_PERF_MEM_USAGE_H_
-
-#include "base/basictypes.h"
-
-// Get the number of bytes currently committed by the system.
-// Returns -1 on failure.
-size_t GetSystemCommitCharge();
-
-// Get and print memory usage information for running chrome processes.
-void PrintChromeMemoryUsageInfo();
-
-#endif // CHROME_TEST_PERF_MEM_USAGE_H_
diff --git a/chrome/test/perf/mem_usage_linux.cc b/chrome/test/perf/mem_usage_linux.cc
deleted file mode 100644
index 568b4fc..0000000
--- a/chrome/test/perf/mem_usage_linux.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) 2009 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 "chrome/test/perf/mem_usage.h"
-
-#include "base/file_util.h"
-#include "base/logging.h"
-#include "base/process_util.h"
-#include "base/string_util.h"
-
-namespace {
-
-// The format of /proc/meminfo is:
-//
-// MemTotal: 8235324 kB
-// MemFree: 1628304 kB
-// Buffers: 429596 kB
-// Cached: 4728232 kB
-// ...
-const size_t kMemTotalIndex = 1;
-const size_t kMemFreeIndex = 4;
-const size_t kMemBuffersIndex = 7;
-const size_t kMemCacheIndex = 10;
-
-} // namespace
-
-size_t GetSystemCommitCharge() {
- // Used memory is: total - free - buffers - caches
- FilePath meminfo_file("/proc/meminfo");
- std::string meminfo_data;
- if (!file_util::ReadFileToString(meminfo_file, &meminfo_data))
- return 0;
- std::vector<std::string> meminfo_fields;
- SplitStringAlongWhitespace(meminfo_data, &meminfo_fields);
-
- if (meminfo_fields.size() < kMemCacheIndex) {
- LOG(ERROR) << "Failed to parse /proc/meminfo. Only found " <<
- meminfo_fields.size() << " fields.";
- return 0;
- }
-
- DCHECK_EQ(meminfo_fields[kMemTotalIndex-1], "MemTotal:");
- DCHECK_EQ(meminfo_fields[kMemFreeIndex-1], "MemFree:");
- DCHECK_EQ(meminfo_fields[kMemBuffersIndex-1], "Buffers:");
- DCHECK_EQ(meminfo_fields[kMemCacheIndex-1], "Cached:");
-
- int result_in_kb;
- result_in_kb = StringToInt(meminfo_fields[kMemTotalIndex]);
- result_in_kb -= StringToInt(meminfo_fields[kMemFreeIndex]);
- result_in_kb -= StringToInt(meminfo_fields[kMemBuffersIndex]);
- result_in_kb -= StringToInt(meminfo_fields[kMemCacheIndex]);
-
- return result_in_kb * 1024;
-}
-
-void PrintChromeMemoryUsageInfo() {
- NOTIMPLEMENTED();
-}
-
diff --git a/chrome/test/perf/mem_usage_mac.cc b/chrome/test/perf/mem_usage_mac.cc
deleted file mode 100644
index 90d87e5..0000000
--- a/chrome/test/perf/mem_usage_mac.cc
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2009 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 "chrome/test/perf/mem_usage.h"
-
-#include <mach/mach.h>
-
-#include <vector>
-
-#include "base/logging.h"
-#include "base/process_util.h"
-#include "chrome/test/chrome_process_util.h"
-
-// Bytes committed by the system.
-size_t GetSystemCommitCharge() {
- host_name_port_t host = mach_host_self();
- mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
- vm_statistics_data_t data;
- kern_return_t kr = host_statistics(host, HOST_VM_INFO,
- reinterpret_cast<host_info_t>(&data),
- &count);
- if (kr)
- return 0;
-
- vm_size_t page_size;
- kr = host_page_size(host, &page_size);
- if (kr)
- return 0;
-
- return data.active_count * page_size;
-}
-
-void PrintChromeMemoryUsageInfo() {
- NOTIMPLEMENTED();
-}
-
diff --git a/chrome/test/perf/mem_usage_win.cc b/chrome/test/perf/mem_usage_win.cc
deleted file mode 100644
index 465b602..0000000
--- a/chrome/test/perf/mem_usage_win.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright (c) 2006-2008 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 "chrome/test/perf/mem_usage.h"
-
-#include <windows.h>
-#include <psapi.h>
-
-#include "base/file_path.h"
-#include "base/path_service.h"
-#include "base/process_util.h"
-#include "base/scoped_ptr.h"
-#include "chrome/common/chrome_constants.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/test/chrome_process_util.h"
-
-// GetPerformanceInfo is not available on WIN2K. So we'll
-// load it on-the-fly.
-const wchar_t kPsapiDllName[] = L"psapi.dll";
-typedef BOOL (WINAPI *GetPerformanceInfoFunction) (
- PPERFORMANCE_INFORMATION pPerformanceInformation,
- DWORD cb);
-
-static BOOL InternalGetPerformanceInfo(
- PPERFORMANCE_INFORMATION pPerformanceInformation, DWORD cb) {
- static GetPerformanceInfoFunction GetPerformanceInfo_func = NULL;
- if (!GetPerformanceInfo_func) {
- HMODULE psapi_dll = ::GetModuleHandle(kPsapiDllName);
- if (psapi_dll)
- GetPerformanceInfo_func = reinterpret_cast<GetPerformanceInfoFunction>(
- GetProcAddress(psapi_dll, "GetPerformanceInfo"));
-
- if (!GetPerformanceInfo_func) {
- // The function could be loaded!
- memset(pPerformanceInformation, 0, cb);
- return FALSE;
- }
- }
- return GetPerformanceInfo_func(pPerformanceInformation, cb);
-}
-
-
-size_t GetSystemCommitCharge() {
- // Get the System Page Size.
- SYSTEM_INFO system_info;
- GetSystemInfo(&system_info);
-
- PERFORMANCE_INFORMATION info;
- if (InternalGetPerformanceInfo(&info, sizeof(info)))
- return info.CommitTotal * system_info.dwPageSize;
- return -1;
-}
-
-void PrintChromeMemoryUsageInfo() {
- printf("\n");
-
- FilePath data_dir;
- PathService::Get(chrome::DIR_USER_DATA, &data_dir);
- int browser_process_pid = ChromeBrowserProcessId(data_dir);
- ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
-
- ChromeProcessList::const_iterator it;
- for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
- base::ProcessHandle process_handle;
- if (!base::OpenPrivilegedProcessHandle(*it, &process_handle)) {
- NOTREACHED();
- }
-
- // TODO(sgk): if/when base::ProcessMetrics can return real memory
- // stats on mac, convert to:
- //
- // scoped_ptr<base::ProcessMetrics> process_metrics;
- // process_metrics.reset(
- // base::ProcessMetrics::CreateProcessMetrics(process_handle));
- scoped_ptr<ChromeTestProcessMetrics> process_metrics;
- process_metrics.reset(
- ChromeTestProcessMetrics::CreateProcessMetrics(process_handle));
-
- size_t peak_virtual_size = process_metrics->GetPeakPagefileUsage();
- size_t current_virtual_size = process_metrics->GetPagefileUsage();
- size_t peak_working_set_size = process_metrics->GetPeakWorkingSetSize();
- size_t current_working_set_size = process_metrics->GetWorkingSetSize();
-
- if (*it == browser_process_pid) {
- wprintf(L"browser_vm_peak = %d\n", peak_virtual_size);
- wprintf(L"browser_vm_current = %d\n", current_virtual_size);
- wprintf(L"browser_ws_peak = %d\n", peak_working_set_size);
- wprintf(L"browser_ws_final = %d\n", current_working_set_size);
- } else {
- wprintf(L"render_vm_peak = %d\n", peak_virtual_size);
- wprintf(L"render_vm_current = %d\n", current_virtual_size);
- wprintf(L"render_ws_peak = %d\n", peak_working_set_size);
- wprintf(L"render_ws_final = %d\n", current_working_set_size);
- }
- };
-}