OLD | NEW |
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 <windows.h> | 5 #include <windows.h> |
6 #include <psapi.h> | 6 #include <psapi.h> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/file_path.h" |
| 10 #include "base/path_service.h" |
9 #include "base/process_util.h" | 11 #include "base/process_util.h" |
10 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
11 #include "chrome/common/chrome_process_filter.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/test/chrome_process_util.h" |
12 #include "chrome/test/perf/mem_usage.h" | 15 #include "chrome/test/perf/mem_usage.h" |
13 | 16 |
14 bool GetMemoryInfo(uint32 process_id, | 17 bool GetMemoryInfo(uint32 process_id, |
15 size_t *peak_virtual_size, | 18 size_t *peak_virtual_size, |
16 size_t *current_virtual_size, | 19 size_t *current_virtual_size, |
17 size_t *peak_working_set_size, | 20 size_t *peak_working_set_size, |
18 size_t *current_working_set_size) { | 21 size_t *current_working_set_size) { |
19 if (!peak_virtual_size || !current_virtual_size) | 22 if (!peak_virtual_size || !current_virtual_size) |
20 return false; | 23 return false; |
21 | 24 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 GetSystemInfo(&system_info); | 76 GetSystemInfo(&system_info); |
74 | 77 |
75 PERFORMANCE_INFORMATION info; | 78 PERFORMANCE_INFORMATION info; |
76 if (InternalGetPerformanceInfo(&info, sizeof(info))) | 79 if (InternalGetPerformanceInfo(&info, sizeof(info))) |
77 return info.CommitTotal * system_info.dwPageSize; | 80 return info.CommitTotal * system_info.dwPageSize; |
78 return -1; | 81 return -1; |
79 } | 82 } |
80 | 83 |
81 void PrintChromeMemoryUsageInfo() { | 84 void PrintChromeMemoryUsageInfo() { |
82 printf("\n"); | 85 printf("\n"); |
83 BrowserProcessFilter chrome_filter(L""); | |
84 base::NamedProcessIterator | |
85 chrome_process_itr(chrome::kBrowserProcessExecutableName, &chrome_filter); | |
86 | 86 |
87 const PROCESSENTRY32* chrome_entry; | 87 FilePath data_dir; |
88 while (chrome_entry = chrome_process_itr.NextProcessEntry()) { | 88 PathService::Get(chrome::DIR_USER_DATA, &data_dir); |
89 uint32 pid = chrome_entry->th32ProcessID; | 89 int browser_process_pid = ChromeBrowserProcessId(data_dir); |
| 90 ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir)); |
| 91 |
| 92 ChromeProcessList::const_iterator it; |
| 93 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) { |
90 size_t peak_virtual_size; | 94 size_t peak_virtual_size; |
91 size_t current_virtual_size; | 95 size_t current_virtual_size; |
92 size_t peak_working_set_size; | 96 size_t peak_working_set_size; |
93 size_t current_working_set_size; | 97 size_t current_working_set_size; |
94 if (GetMemoryInfo(pid, &peak_virtual_size, ¤t_virtual_size, | 98 if (GetMemoryInfo(*it, &peak_virtual_size, ¤t_virtual_size, |
95 &peak_working_set_size, ¤t_working_set_size)) { | 99 &peak_working_set_size, ¤t_working_set_size)) { |
96 if (pid == chrome_filter.browser_process_id()) { | 100 if (*it == browser_process_pid) { |
97 wprintf(L"browser_vm_peak = %d\n", peak_virtual_size); | 101 wprintf(L"browser_vm_peak = %d\n", peak_virtual_size); |
98 wprintf(L"browser_vm_current = %d\n", current_virtual_size); | 102 wprintf(L"browser_vm_current = %d\n", current_virtual_size); |
99 wprintf(L"browser_ws_peak = %d\n", peak_working_set_size); | 103 wprintf(L"browser_ws_peak = %d\n", peak_working_set_size); |
100 wprintf(L"browser_ws_final = %d\n", current_working_set_size); | 104 wprintf(L"browser_ws_final = %d\n", current_working_set_size); |
101 } else { | 105 } else { |
102 wprintf(L"render_vm_peak = %d\n", peak_virtual_size); | 106 wprintf(L"render_vm_peak = %d\n", peak_virtual_size); |
103 wprintf(L"render_vm_current = %d\n", current_virtual_size); | 107 wprintf(L"render_vm_current = %d\n", current_virtual_size); |
104 wprintf(L"render_ws_peak = %d\n", peak_working_set_size); | 108 wprintf(L"render_ws_peak = %d\n", peak_working_set_size); |
105 wprintf(L"render_ws_final = %d\n", current_working_set_size); | 109 wprintf(L"render_ws_final = %d\n", current_working_set_size); |
106 } | 110 } |
107 } | 111 } |
108 }; | 112 }; |
109 } | 113 } |
OLD | NEW |