summaryrefslogtreecommitdiffstats
path: root/chrome
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
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')
-rwxr-xr-xchrome/chrome.gyp4
-rw-r--r--chrome/test/memory_test/memory_test.cc7
-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
-rw-r--r--chrome/test/reliability/page_load_test.cc7
7 files changed, 3 insertions, 226 deletions
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 51dc100..d5b7a5c 100755
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -4078,10 +4078,6 @@
'test/chrome_process_util_linux.cc',
'test/chrome_process_util_mac.cc',
'test/chrome_process_util_win.cc',
- 'test/perf/mem_usage_linux.cc',
- 'test/perf/mem_usage_mac.cc',
- 'test/perf/mem_usage_win.cc',
- 'test/perf/mem_usage.h',
'test/test_browser_window.h',
'test/testing_profile.cc',
'test/testing_profile.h',
diff --git a/chrome/test/memory_test/memory_test.cc b/chrome/test/memory_test/memory_test.cc
index 3c55d9a..8134c80 100644
--- a/chrome/test/memory_test/memory_test.cc
+++ b/chrome/test/memory_test/memory_test.cc
@@ -18,7 +18,6 @@
#include "chrome/test/automation/window_proxy.h"
#include "chrome/test/chrome_process_util.h"
#include "chrome/test/ui/ui_test.h"
-#include "chrome/test/perf/mem_usage.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -135,7 +134,7 @@ class MemoryTest : public UITest {
// Record the initial CommitCharge. This is a system-wide measurement,
// so if other applications are running, they can create variance in this
// test.
- size_t start_size = GetSystemCommitCharge();
+ size_t start_size = base::GetSystemCommitCharge();
// Cycle through the URLs.
scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
@@ -221,8 +220,8 @@ class MemoryTest : public UITest {
PlatformThread::Sleep(100);
}
- size_t stop_size = GetSystemCommitCharge();
- PrintResults(test_name, stop_size - start_size);
+ size_t stop_size = base::GetSystemCommitCharge();
+ PrintResults(test_name, (stop_size - start_size) / 1024);
}
void PrintResults(const char* test_name, size_t commit_size) {
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);
- }
- };
-}
diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc
index ffaa63a..ef7f66d 100644
--- a/chrome/test/reliability/page_load_test.cc
+++ b/chrome/test/reliability/page_load_test.cc
@@ -60,7 +60,6 @@
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/automation/window_proxy.h"
#include "chrome/test/ui/ui_test.h"
-#include "chrome/test/perf/mem_usage.h"
#include "chrome/test/reliability/page_load_test.h"
#include "net/base/net_util.h"
@@ -608,12 +607,6 @@ TEST_F(PageLoadTest, Reliability) {
} else {
NavigateThroughURLList(log_file);
}
-
-// TODO(estade): port.
-#if defined(OS_WIN)
- if (g_memory_usage)
- PrintChromeMemoryUsageInfo();
-#endif // defined(OS_WIN)
}
if (!g_end_url.empty()) {