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

Side by Side Diff: chrome/test/page_cycler/page_cycler_test.cc

Issue 54003: Replace chrome_process_filter with chrome_process_util. (Closed)
Patch Set: error handling Created 11 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
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "chrome/browser/net/url_fixer_upper.h" 11 #include "chrome/browser/net/url_fixer_upper.h"
12 #include "chrome/common/chrome_constants.h" 12 #include "chrome/common/chrome_constants.h"
13 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
14 #if defined(OS_WIN)
15 // TODO(port): Enable when chrome_process_filter.h is ported.
16 #include "chrome/common/chrome_process_filter.h"
17 #endif // defined(OS_WIN)
18 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/automation/tab_proxy.h" 15 #include "chrome/test/automation/tab_proxy.h"
20 #include "chrome/test/automation/window_proxy.h" 16 #include "chrome/test/automation/window_proxy.h"
17 #include "chrome/test/chrome_process_util.h"
21 #include "chrome/test/ui/ui_test.h" 18 #include "chrome/test/ui/ui_test.h"
22 #include "chrome/test/perf/mem_usage.h" 19 #include "chrome/test/perf/mem_usage.h"
23 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
24 #include "net/base/net_util.h" 21 #include "net/base/net_util.h"
25 22
26 #ifndef NDEBUG 23 #ifndef NDEBUG
27 #define TEST_ITERATIONS "2" 24 #define TEST_ITERATIONS "2"
28 #else 25 #else
29 #define TEST_ITERATIONS "10" 26 #define TEST_ITERATIONS "10"
30 #endif 27 #endif
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 std::string cookie; 78 std::string cookie;
82 ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_pages", &cookie)); 79 ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_pages", &cookie));
83 pages->assign(UTF8ToWide(cookie)); 80 pages->assign(UTF8ToWide(cookie));
84 ASSERT_FALSE(pages->empty()); 81 ASSERT_FALSE(pages->empty());
85 ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_timings", &cookie)); 82 ASSERT_TRUE(tab->GetCookieByName(test_url, "__pc_timings", &cookie));
86 timings->assign(cookie); 83 timings->assign(cookie);
87 ASSERT_FALSE(timings->empty()); 84 ASSERT_FALSE(timings->empty());
88 } 85 }
89 86
90 #if defined(OS_WIN) 87 #if defined(OS_WIN)
91 // TODO(port): Code below depends on BrowserProcessFilter and has windowsisms. 88 // TODO(port): Port chrome_process_util and remove windowsisms.
92 void PrintIOPerfInfo(const char* test_name) { 89 void PrintIOPerfInfo(const char* test_name) {
93 BrowserProcessFilter chrome_filter(L""); 90 FilePath data_dir;
94 base::NamedProcessIterator 91 PathService::Get(chrome::DIR_USER_DATA, &data_dir);
95 chrome_process_itr(chrome::kBrowserProcessExecutableName, 92 int browser_process_pid = ChromeBrowserProcessId(data_dir);
96 &chrome_filter); 93 ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
97 94
98 const PROCESSENTRY32* chrome_entry; 95 ChromeProcessList::const_iterator it;
99 while(chrome_entry = chrome_process_itr.NextProcessEntry()) { 96 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
100 uint32 pid = chrome_entry->th32ProcessID; 97 base::ProcessHandle process_handle;
101 HANDLE process_handle = OpenProcess(PROCESS_QUERY_INFORMATION, 98 if (!base::OpenProcessHandle(*it, &process_handle)) {
102 false, 99 NOTREACHED();
103 pid); 100 }
104 101
105 scoped_ptr<base::ProcessMetrics> process_metrics; 102 scoped_ptr<base::ProcessMetrics> process_metrics;
106 IO_COUNTERS io_counters; 103 IO_COUNTERS io_counters;
107 process_metrics.reset( 104 process_metrics.reset(
108 base::ProcessMetrics::CreateProcessMetrics(process_handle)); 105 base::ProcessMetrics::CreateProcessMetrics(process_handle));
109 ZeroMemory(&io_counters, sizeof(io_counters)); 106 ZeroMemory(&io_counters, sizeof(io_counters));
110 107
111 if (process_metrics.get()->GetIOCounters(&io_counters)) { 108 if (process_metrics.get()->GetIOCounters(&io_counters)) {
112 // Print out IO performance. We assume that the values can be 109 // Print out IO performance. We assume that the values can be
113 // converted to size_t (they're reported as ULONGLONG, 64-bit numbers). 110 // converted to size_t (they're reported as ULONGLONG, 64-bit numbers).
114 std::string chrome_name = 111 std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r";
115 (pid == chrome_filter.browser_process_id()) ? "_b" : "_r";
116 112
117 PrintResult("read_op", chrome_name, 113 PrintResult("read_op", chrome_name,
118 "r_op" + chrome_name + test_name, 114 "r_op" + chrome_name + test_name,
119 static_cast<size_t>(io_counters.ReadOperationCount), "", 115 static_cast<size_t>(io_counters.ReadOperationCount), "",
120 false /* not important */); 116 false /* not important */);
121 PrintResult("write_op", chrome_name, 117 PrintResult("write_op", chrome_name,
122 "w_op" + chrome_name + test_name, 118 "w_op" + chrome_name + test_name,
123 static_cast<size_t>(io_counters.WriteOperationCount), "", 119 static_cast<size_t>(io_counters.WriteOperationCount), "",
124 false /* not important */); 120 false /* not important */);
125 PrintResult("other_op", chrome_name, 121 PrintResult("other_op", chrome_name,
(...skipping 23 matching lines...) Expand all
149 145
150 total = static_cast<size_t>((io_counters.ReadTransferCount + 146 total = static_cast<size_t>((io_counters.ReadTransferCount +
151 io_counters.WriteTransferCount + 147 io_counters.WriteTransferCount +
152 io_counters.OtherTransferCount) / 1024); 148 io_counters.OtherTransferCount) / 1024);
153 PrintResult("total_byte", chrome_name, 149 PrintResult("total_byte", chrome_name,
154 "IO_b" + chrome_name + test_name, 150 "IO_b" + chrome_name + test_name,
155 total, "kb", true /* important */); 151 total, "kb", true /* important */);
156 152
157 153
158 } 154 }
155
156 base::CloseProcessHandle(process_handle);
159 } 157 }
160 } 158 }
161 159
162 void PrintMemoryUsageInfo(const char* test_name) { 160 void PrintMemoryUsageInfo(const char* test_name) {
163 BrowserProcessFilter chrome_filter(L""); 161 FilePath data_dir;
164 base::NamedProcessIterator 162 PathService::Get(chrome::DIR_USER_DATA, &data_dir);
165 chrome_process_itr(chrome::kBrowserProcessExecutableName, 163 int browser_process_pid = ChromeBrowserProcessId(data_dir);
166 &chrome_filter); 164 ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
167 165
168 const PROCESSENTRY32* chrome_entry; 166 ChromeProcessList::const_iterator it;
169 while(chrome_entry = chrome_process_itr.NextProcessEntry()) { 167 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
170 uint32 pid = chrome_entry->th32ProcessID;
171 size_t peak_virtual_size; 168 size_t peak_virtual_size;
172 size_t current_virtual_size; 169 size_t current_virtual_size;
173 size_t peak_working_set_size; 170 size_t peak_working_set_size;
174 size_t current_working_set_size; 171 size_t current_working_set_size;
175 if (GetMemoryInfo(pid, &peak_virtual_size, &current_virtual_size, 172 if (GetMemoryInfo(*it, &peak_virtual_size, &current_virtual_size,
176 &peak_working_set_size, &current_working_set_size)) { 173 &peak_working_set_size, &current_working_set_size)) {
177 174
178 std::string chrome_name = 175 std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r";
179 (pid == chrome_filter.browser_process_id()) ? "_b" : "_r";
180 176
181 std::string trace_name(test_name); 177 std::string trace_name(test_name);
182 PrintResult("vm_peak", chrome_name, 178 PrintResult("vm_peak", chrome_name,
183 "vm_pk" + chrome_name + trace_name, 179 "vm_pk" + chrome_name + trace_name,
184 peak_virtual_size, "bytes", 180 peak_virtual_size, "bytes",
185 true /* important */); 181 true /* important */);
186 PrintResult("vm_final", chrome_name, 182 PrintResult("vm_final", chrome_name,
187 "vm_f" + chrome_name + trace_name, 183 "vm_f" + chrome_name + trace_name,
188 current_virtual_size, "bytes", 184 current_virtual_size, "bytes",
189 false /* not important */); 185 false /* not important */);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 RunTest("dom", true); 326 RunTest("dom", true);
331 } 327 }
332 328
333 TEST_F(PageCyclerTest, BloatHttp) { 329 TEST_F(PageCyclerTest, BloatHttp) {
334 RunTest("bloat", true); 330 RunTest("bloat", true);
335 } 331 }
336 332
337 TEST_F(PageCyclerReferenceTest, BloatHttp) { 333 TEST_F(PageCyclerReferenceTest, BloatHttp) {
338 RunTest("bloat", true); 334 RunTest("bloat", true);
339 } 335 }
OLDNEW
« no previous file with comments | « chrome/test/memory_test/memory_test.vcproj ('k') | chrome/test/page_cycler/page_cycler_tests.vcproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698