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

Side by Side Diff: chrome/test/perf/perf_test.cc

Issue 868543002: Move OpenProcessHandle to Process::Open. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/test/perf/perf_test.h" 5 #include "chrome/test/perf/perf_test.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/process/process.h"
10 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "chrome/test/base/chrome_process_util.h" 13 #include "chrome/test/base/chrome_process_util.h"
13 #include "testing/perf/perf_test.h" 14 #include "testing/perf/perf_test.h"
14 15
15 namespace perf_test { 16 namespace perf_test {
16 17
17 void PrintIOPerfInfo(const std::string& test_name, 18 void PrintIOPerfInfo(const std::string& test_name,
18 const ChromeProcessList& chrome_processes, 19 const ChromeProcessList& chrome_processes,
19 base::ProcessId browser_pid) { 20 base::ProcessId browser_pid) {
(...skipping 25 matching lines...) Expand all
45 size_t write_byte_b = 0; 46 size_t write_byte_b = 0;
46 size_t write_byte_r = 0; 47 size_t write_byte_r = 0;
47 size_t other_byte_b = 0; 48 size_t other_byte_b = 0;
48 size_t other_byte_r = 0; 49 size_t other_byte_r = 0;
49 size_t total_byte_b = 0; 50 size_t total_byte_b = 0;
50 size_t total_byte_r = 0; 51 size_t total_byte_r = 0;
51 52
52 std::string output; 53 std::string output;
53 ChromeProcessList::const_iterator it; 54 ChromeProcessList::const_iterator it;
54 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) { 55 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
55 base::ProcessHandle process_handle; 56 base::Process process = base::Process::Open(*it);
56 if (!base::OpenProcessHandle(*it, &process_handle)) { 57 if (!process.IsValid()) {
57 NOTREACHED(); 58 NOTREACHED();
58 return output; 59 return output;
59 } 60 }
60 61
61 // TODO(sgk): if/when base::ProcessMetrics returns real stats on mac: 62 // TODO(sgk): if/when base::ProcessMetrics returns real stats on mac:
62 // scoped_ptr<base::ProcessMetrics> process_metrics( 63 // scoped_ptr<base::ProcessMetrics> process_metrics(
63 // base::ProcessMetrics::CreateProcessMetrics(process_handle)); 64 // base::ProcessMetrics::CreateProcessMetrics(process.Handle()));
64 scoped_ptr<ChromeTestProcessMetrics> process_metrics( 65 scoped_ptr<ChromeTestProcessMetrics> process_metrics(
65 ChromeTestProcessMetrics::CreateProcessMetrics(process_handle)); 66 ChromeTestProcessMetrics::CreateProcessMetrics(process.Handle()));
66 base::IoCounters io_counters; 67 base::IoCounters io_counters;
67 memset(&io_counters, 0, sizeof(io_counters)); 68 memset(&io_counters, 0, sizeof(io_counters));
68 69
69 if (process_metrics.get()->GetIOCounters(&io_counters)) { 70 if (process_metrics.get()->GetIOCounters(&io_counters)) {
70 // Print out IO performance. We assume that the values can be 71 // Print out IO performance. We assume that the values can be
71 // converted to size_t (they're reported as ULONGLONG, 64-bit numbers). 72 // converted to size_t (they're reported as ULONGLONG, 64-bit numbers).
72 std::string chrome_name = (*it == browser_pid) ? "_b" : "_r"; 73 std::string chrome_name = (*it == browser_pid) ? "_b" : "_r";
73 74
74 size_t read_op = static_cast<size_t>(io_counters.ReadOperationCount); 75 size_t read_op = static_cast<size_t>(io_counters.ReadOperationCount);
75 size_t write_op = static_cast<size_t>(io_counters.WriteOperationCount); 76 size_t write_op = static_cast<size_t>(io_counters.WriteOperationCount);
(...skipping 26 matching lines...) Expand all
102 read_op_r += read_op; 103 read_op_r += read_op;
103 write_op_r += write_op; 104 write_op_r += write_op;
104 other_op_r += other_op; 105 other_op_r += other_op;
105 total_op_r += total_op; 106 total_op_r += total_op;
106 read_byte_r += read_byte; 107 read_byte_r += read_byte;
107 write_byte_r += write_byte; 108 write_byte_r += write_byte;
108 other_byte_r += other_byte; 109 other_byte_r += other_byte;
109 total_byte_r += total_byte; 110 total_byte_r += total_byte;
110 } 111 }
111 } 112 }
112
113 base::CloseProcessHandle(process_handle);
114 } 113 }
115 114
116 std::string t_name(test_name); 115 std::string t_name(test_name);
117 AppendResult(output, 116 AppendResult(output,
118 "read_op_b", 117 "read_op_b",
119 std::string(), 118 std::string(),
120 "r_op_b" + t_name, 119 "r_op_b" + t_name,
121 read_op_b, 120 read_op_b,
122 "ops", 121 "ops",
123 false); 122 false);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 size_t browser_peak_working_set_size = 0; 260 size_t browser_peak_working_set_size = 0;
262 size_t renderer_total_peak_virtual_size = 0; 261 size_t renderer_total_peak_virtual_size = 0;
263 size_t renderer_total_peak_working_set_size = 0; 262 size_t renderer_total_peak_working_set_size = 0;
264 size_t renderer_single_peak_virtual_size = 0; 263 size_t renderer_single_peak_virtual_size = 0;
265 size_t renderer_single_peak_working_set_size = 0; 264 size_t renderer_single_peak_working_set_size = 0;
266 #endif 265 #endif
267 266
268 std::string output; 267 std::string output;
269 ChromeProcessList::const_iterator it; 268 ChromeProcessList::const_iterator it;
270 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) { 269 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
271 base::ProcessHandle process_handle; 270 base::Process process = base::Process::Open(*it);
272 if (!base::OpenProcessHandle(*it, &process_handle)) { 271 if (!process.IsValid()) {
273 NOTREACHED(); 272 NOTREACHED();
274 return output; 273 return output;
275 } 274 }
276 275
277 // TODO(sgk): if/when base::ProcessMetrics returns real stats on mac: 276 // TODO(sgk): if/when base::ProcessMetrics returns real stats on mac:
278 // scoped_ptr<base::ProcessMetrics> process_metrics( 277 // scoped_ptr<base::ProcessMetrics> process_metrics(
279 // base::ProcessMetrics::CreateProcessMetrics(process_handle)); 278 // base::ProcessMetrics::CreateProcessMetrics(process.Handle()));
280 scoped_ptr<ChromeTestProcessMetrics> process_metrics( 279 scoped_ptr<ChromeTestProcessMetrics> process_metrics(
281 ChromeTestProcessMetrics::CreateProcessMetrics(process_handle)); 280 ChromeTestProcessMetrics::CreateProcessMetrics(process.Handle()));
282 281
283 size_t current_virtual_size = process_metrics->GetPagefileUsage(); 282 size_t current_virtual_size = process_metrics->GetPagefileUsage();
284 size_t current_working_set_size = process_metrics->GetWorkingSetSize(); 283 size_t current_working_set_size = process_metrics->GetWorkingSetSize();
285 284
286 if (*it == browser_pid) { 285 if (*it == browser_pid) {
287 browser_virtual_size = current_virtual_size; 286 browser_virtual_size = current_virtual_size;
288 browser_working_set_size = current_working_set_size; 287 browser_working_set_size = current_working_set_size;
289 } else { 288 } else {
290 renderer_virtual_size += current_virtual_size; 289 renderer_virtual_size += current_virtual_size;
291 renderer_working_set_size += current_working_set_size; 290 renderer_working_set_size += current_working_set_size;
(...skipping 11 matching lines...) Expand all
303 if (peak_virtual_size > renderer_single_peak_virtual_size) { 302 if (peak_virtual_size > renderer_single_peak_virtual_size) {
304 renderer_single_peak_virtual_size = peak_virtual_size; 303 renderer_single_peak_virtual_size = peak_virtual_size;
305 } 304 }
306 if (peak_working_set_size > renderer_single_peak_working_set_size) { 305 if (peak_working_set_size > renderer_single_peak_working_set_size) {
307 renderer_single_peak_working_set_size = peak_working_set_size; 306 renderer_single_peak_working_set_size = peak_working_set_size;
308 } 307 }
309 renderer_total_peak_virtual_size += peak_virtual_size; 308 renderer_total_peak_virtual_size += peak_virtual_size;
310 renderer_total_peak_working_set_size += peak_working_set_size; 309 renderer_total_peak_working_set_size += peak_working_set_size;
311 } 310 }
312 #endif 311 #endif
313
314 base::CloseProcessHandle(process_handle);
315 } 312 }
316 313
317 std::string trace_name(test_name); 314 std::string trace_name(test_name);
318 #if defined(OS_WIN) 315 #if defined(OS_WIN)
319 AppendResult(output, "vm_peak_b", "", "vm_pk_b" + trace_name, 316 AppendResult(output, "vm_peak_b", "", "vm_pk_b" + trace_name,
320 browser_peak_virtual_size, "bytes", 317 browser_peak_virtual_size, "bytes",
321 false /* not important */); 318 false /* not important */);
322 AppendResult(output, "ws_peak_b", "", "ws_pk_b" + trace_name, 319 AppendResult(output, "ws_peak_b", "", "ws_pk_b" + trace_name,
323 browser_peak_working_set_size, "bytes", 320 browser_peak_working_set_size, "bytes",
324 false /* not important */); 321 false /* not important */);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 std::string(), 400 std::string(),
404 "proc_" + trace_name, 401 "proc_" + trace_name,
405 chrome_processes.size(), 402 chrome_processes.size(),
406 "count", 403 "count",
407 false /* not important */); 404 false /* not important */);
408 405
409 return output; 406 return output;
410 } 407 }
411 408
412 } // namespace perf_test 409 } // namespace perf_test
OLDNEW
« no previous file with comments | « chrome/test/base/chrome_process_util.cc ('k') | components/browser_watcher/watcher_metrics_provider_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698