summaryrefslogtreecommitdiffstats
path: root/chrome/test/page_cycler
diff options
context:
space:
mode:
authorsgk@google.com <sgk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 20:48:04 +0000
committersgk@google.com <sgk@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 20:48:04 +0000
commit08f0a19132581e09be48b13933ec2a90813fd052 (patch)
tree0e799425dfa581866b0e6514b6cfecc4172c8be8 /chrome/test/page_cycler
parent2775cce1a62be565e13d85b49d5fa110c02f0e78 (diff)
downloadchromium_src-08f0a19132581e09be48b13933ec2a90813fd052.zip
chromium_src-08f0a19132581e09be48b13933ec2a90813fd052.tar.gz
chromium_src-08f0a19132581e09be48b13933ec2a90813fd052.tar.bz2
Prep for printing common memory stats from page_cycler_tests and memory_test:
Move PrintIOPerfInfo(), PrintMemoryUsageInfo() and PrintSystemCommitCharge() into the UITest base class so both page_cycler and memory_test will be able to use them. Make the user data dir a parameter so that memory_test will be able to point to its temporary copy. BUG=none TEST=none Review URL: http://codereview.chromium.org/402052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32538 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/page_cycler')
-rw-r--r--chrome/test/page_cycler/page_cycler_test.cc172
1 files changed, 10 insertions, 162 deletions
diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc
index 942003d..234b021 100644
--- a/chrome/test/page_cycler/page_cycler_test.cc
+++ b/chrome/test/page_cycler/page_cycler_test.cc
@@ -226,164 +226,6 @@ class PageCyclerTest : public UITest {
ASSERT_FALSE(timings->empty());
}
- void PrintIOPerfInfo(const char* test_name) {
- 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();
- }
-
- scoped_ptr<base::ProcessMetrics> process_metrics;
- process_metrics.reset(
- base::ProcessMetrics::CreateProcessMetrics(process_handle));
- IoCounters io_counters;
- memset(&io_counters, 0, sizeof(io_counters));
-
- if (process_metrics.get()->GetIOCounters(&io_counters)) {
- // Print out IO performance. We assume that the values can be
- // converted to size_t (they're reported as ULONGLONG, 64-bit numbers).
- std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r";
-
- PrintResult("read_op", chrome_name,
- "r_op" + chrome_name + test_name,
- static_cast<size_t>(io_counters.ReadOperationCount), "",
- false /* not important */);
- PrintResult("write_op", chrome_name,
- "w_op" + chrome_name + test_name,
- static_cast<size_t>(io_counters.WriteOperationCount), "",
- false /* not important */);
- PrintResult("other_op", chrome_name,
- "o_op" + chrome_name + test_name,
- static_cast<size_t>(io_counters.OtherOperationCount), "",
- false /* not important */);
-
- size_t total = static_cast<size_t>(io_counters.ReadOperationCount +
- io_counters.WriteOperationCount +
- io_counters.OtherOperationCount);
- PrintResult("total_op", chrome_name,
- "IO_op" + chrome_name + test_name,
- total, "", true /* important */);
-
- PrintResult("read_byte", chrome_name,
- "r_b" + chrome_name + test_name,
- static_cast<size_t>(io_counters.ReadTransferCount / 1024),
- "kb", false /* not important */);
- PrintResult("write_byte", chrome_name,
- "w_b" + chrome_name + test_name,
- static_cast<size_t>(io_counters.WriteTransferCount / 1024),
- "kb", false /* not important */);
- PrintResult("other_byte", chrome_name,
- "o_b" + chrome_name + test_name,
- static_cast<size_t>(io_counters.OtherTransferCount / 1024),
- "kb", false /* not important */);
-
- total = static_cast<size_t>((io_counters.ReadTransferCount +
- io_counters.WriteTransferCount +
- io_counters.OtherTransferCount) / 1024);
- PrintResult("total_byte", chrome_name,
- "IO_b" + chrome_name + test_name,
- total, "kb", true /* important */);
- }
-
- base::CloseProcessHandle(process_handle);
- }
- }
-
- void PrintMemoryUsageInfo(const char* test_name) {
- FilePath data_dir;
- PathService::Get(chrome::DIR_USER_DATA, &data_dir);
- int browser_process_pid = ChromeBrowserProcessId(data_dir);
- ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
-
-#if !defined(OS_MACOSX)
- 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();
- }
-
- scoped_ptr<base::ProcessMetrics> process_metrics;
- process_metrics.reset(
- base::ProcessMetrics::CreateProcessMetrics(process_handle));
-
- std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r";
-
- std::string trace_name(test_name);
-#if defined(OS_WIN)
- PrintResult("vm_peak", chrome_name,
- "vm_pk" + chrome_name + trace_name,
- process_metrics->GetPeakPagefileUsage(), "bytes",
- true /* important */);
- PrintResult("vm_final", chrome_name,
- "vm_f" + chrome_name + trace_name,
- process_metrics->GetPagefileUsage(), "bytes",
- false /* not important */);
- PrintResult("ws_peak", chrome_name,
- "ws_pk" + chrome_name + trace_name,
- process_metrics->GetPeakWorkingSetSize(), "bytes",
- true /* important */);
- PrintResult("ws_final", chrome_name,
- "ws_f" + chrome_name + trace_name,
- process_metrics->GetWorkingSetSize(), "bytes",
- false /* not important */);
-#elif defined(OS_LINUX)
- PrintResult("vm_size_final", chrome_name,
- "vm_size_f" + chrome_name + trace_name,
- process_metrics->GetPagefileUsage(), "bytes",
- true /* important */);
- PrintResult("vm_rss_final", chrome_name,
- "vm_rss_f" + chrome_name + trace_name,
- process_metrics->GetWorkingSetSize(), "bytes",
- true /* important */);
-#else
- NOTIMPLEMENTED();
-#endif
- base::CloseProcessHandle(process_handle);
- }
-
-#else // !defined(OS_MACOSX)
-
- // There is no way to get memory info from one process on another process
- // without privileges, this means the base methods for doing this can't be
- // made to work. Instead we use a helper that invokes ps to collect the
- // data so we have it for the unittest.
-
- MacChromeProcessInfoList process_infos(
- GetRunningMacProcessInfo(chrome_processes));
- MacChromeProcessInfoList::const_iterator it;
- for (it = process_infos.begin(); it != process_infos.end(); ++it) {
- const MacChromeProcessInfo &process_info = *it;
-
- std::string chrome_name =
- (process_info.pid == browser_process_pid) ? "_b" : "_r";
- std::string trace_name(test_name);
-
- PrintResult("vm_size_final", chrome_name,
- "vm_size_f" + chrome_name + trace_name,
- static_cast<size_t>(process_info.vsz_in_kb) * 1024, "bytes",
- true /* important */);
- PrintResult("vm_rss_final", chrome_name,
- "vm_rss_f" + chrome_name + trace_name,
- static_cast<size_t>(process_info.rsz_in_kb) * 1024, "bytes",
- true /* important */);
- }
-
-#endif // !defined(OS_MACOSX)
- }
-
- void PrintSystemCommitCharge(const char* test_name, size_t charge) {
- std::string trace_name(test_name);
- PrintResult("commit_charge", "", "cc" + trace_name, charge, "kb",
- true /* important */);
- }
-
// When use_http is true, the test name passed here will be used directly in
// the path to the test data, so it must be safe for use in a URL without
// escaping. (No pound (#), question mark (?), semicolon (;), non-ASCII, or
@@ -397,8 +239,11 @@ class PageCyclerTest : public UITest {
return;
size_t stop_size = base::GetSystemCommitCharge();
- PrintMemoryUsageInfo(suffix);
- PrintIOPerfInfo(suffix);
+ FilePath data_dir;
+ PathService::Get(chrome::DIR_USER_DATA, &data_dir);
+
+ PrintMemoryUsageInfo(suffix, data_dir);
+ PrintIOPerfInfo(suffix, data_dir);
PrintSystemCommitCharge(suffix, stop_size - start_size);
std::string trace_name = "t" + std::string(suffix);
@@ -444,8 +289,11 @@ class PageCyclerReferenceTest : public PageCyclerTest {
return;
size_t stop_size = base::GetSystemCommitCharge();
- PrintMemoryUsageInfo("_ref");
- PrintIOPerfInfo("_ref");
+ FilePath data_dir;
+ PathService::Get(chrome::DIR_USER_DATA, &data_dir);
+
+ PrintMemoryUsageInfo("_ref", data_dir);
+ PrintIOPerfInfo("_ref", data_dir);
PrintSystemCommitCharge("_ref", stop_size - start_size);
PrintResultList("times", "", "t_ref", timings, "ms",