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

Side by Side Diff: chrome/test/ui/ui_test.cc

Issue 402104: Convert memory_test to use the common stats-reporting methods in UITest.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: make the commit_charge unimportant so page load time is displayed on the default overview Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/memory_test/memory_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/ui/ui_test.h" 5 #include "chrome/test/ui/ui_test.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/sql/connection.h" 10 #include "app/sql/connection.h"
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 yesterday_str.c_str()); 1176 yesterday_str.c_str());
1177 ASSERT_TRUE(db.Execute(query.c_str())); 1177 ASSERT_TRUE(db.Execute(query.c_str()));
1178 db.Close(); 1178 db.Close();
1179 file_util::EvictFileFromSystemCache(history); 1179 file_util::EvictFileFromSystemCache(history);
1180 } 1180 }
1181 1181
1182 void UITest::PrintIOPerfInfo(const char* test_name, FilePath data_dir) { 1182 void UITest::PrintIOPerfInfo(const char* test_name, FilePath data_dir) {
1183 int browser_process_pid = ChromeBrowserProcessId(data_dir); 1183 int browser_process_pid = ChromeBrowserProcessId(data_dir);
1184 ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir)); 1184 ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
1185 1185
1186 size_t read_op_b = 0;
1187 size_t read_op_r = 0;
1188 size_t write_op_b = 0;
1189 size_t write_op_r = 0;
1190 size_t other_op_b = 0;
1191 size_t other_op_r = 0;
1192 size_t total_op_b = 0;
1193 size_t total_op_r = 0;
1194
1195 size_t read_byte_b = 0;
1196 size_t read_byte_r = 0;
1197 size_t write_byte_b = 0;
1198 size_t write_byte_r = 0;
1199 size_t other_byte_b = 0;
1200 size_t other_byte_r = 0;
1201 size_t total_byte_b = 0;
1202 size_t total_byte_r = 0;
1203
1186 ChromeProcessList::const_iterator it; 1204 ChromeProcessList::const_iterator it;
1187 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) { 1205 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
1188 base::ProcessHandle process_handle; 1206 base::ProcessHandle process_handle;
1189 if (!base::OpenPrivilegedProcessHandle(*it, &process_handle)) { 1207 if (!base::OpenPrivilegedProcessHandle(*it, &process_handle)) {
1190 NOTREACHED(); 1208 NOTREACHED();
1191 return; 1209 return;
1192 } 1210 }
1193 1211
1194 scoped_ptr<base::ProcessMetrics> process_metrics( 1212 // TODO(sgk): if/when base::ProcessMetrics returns real stats on mac:
1195 base::ProcessMetrics::CreateProcessMetrics(process_handle)); 1213 //scoped_ptr<base::ProcessMetrics> process_metrics(
1214 // base::ProcessMetrics::CreateProcessMetrics(process_handle));
1215 scoped_ptr<ChromeTestProcessMetrics> process_metrics(
1216 ChromeTestProcessMetrics::CreateProcessMetrics(process_handle));
1196 IoCounters io_counters; 1217 IoCounters io_counters;
1197 memset(&io_counters, 0, sizeof(io_counters)); 1218 memset(&io_counters, 0, sizeof(io_counters));
1198 1219
1199 if (process_metrics.get()->GetIOCounters(&io_counters)) { 1220 if (process_metrics.get()->GetIOCounters(&io_counters)) {
1200 // Print out IO performance. We assume that the values can be 1221 // Print out IO performance. We assume that the values can be
1201 // converted to size_t (they're reported as ULONGLONG, 64-bit numbers). 1222 // converted to size_t (they're reported as ULONGLONG, 64-bit numbers).
1202 std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r"; 1223 std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r";
1203 1224
1204 PrintResult("read_op", chrome_name, 1225 size_t read_op = static_cast<size_t>(io_counters.ReadOperationCount);
1205 "r_op" + chrome_name + test_name, 1226 size_t write_op = static_cast<size_t>(io_counters.WriteOperationCount);
1206 static_cast<size_t>(io_counters.ReadOperationCount), "", 1227 size_t other_op = static_cast<size_t>(io_counters.OtherOperationCount);
1207 false /* not important */); 1228 size_t total_op = static_cast<size_t>(io_counters.ReadOperationCount +
1208 PrintResult("write_op", chrome_name, 1229 io_counters.WriteOperationCount +
1209 "w_op" + chrome_name + test_name, 1230 io_counters.OtherOperationCount);
1210 static_cast<size_t>(io_counters.WriteOperationCount), "",
1211 false /* not important */);
1212 PrintResult("other_op", chrome_name,
1213 "o_op" + chrome_name + test_name,
1214 static_cast<size_t>(io_counters.OtherOperationCount), "",
1215 false /* not important */);
1216 1231
1217 size_t total = static_cast<size_t>(io_counters.ReadOperationCount + 1232 size_t read_byte = static_cast<size_t>(io_counters.ReadTransferCount
1218 io_counters.WriteOperationCount + 1233 / 1024);
1219 io_counters.OtherOperationCount); 1234 size_t write_byte = static_cast<size_t>(io_counters.WriteTransferCount
1220 PrintResult("total_op", chrome_name, 1235 / 1024);
1221 "IO_op" + chrome_name + test_name, 1236 size_t other_byte = static_cast<size_t>(io_counters.OtherTransferCount
1222 total, "", true /* important */); 1237 / 1024);
1238 size_t total_byte = static_cast<size_t>((io_counters.ReadTransferCount +
1239 io_counters.WriteTransferCount +
1240 io_counters.OtherTransferCount)
1241 / 1024);
1223 1242
1224 PrintResult("read_byte", chrome_name, 1243 if (*it == browser_process_pid) {
1225 "r_b" + chrome_name + test_name, 1244 read_op_b = read_op;
1226 static_cast<size_t>(io_counters.ReadTransferCount / 1024), 1245 write_op_b = write_op;
1227 "kb", false /* not important */); 1246 other_op_b = other_op;
1228 PrintResult("write_byte", chrome_name, 1247 total_op_b = total_op;
1229 "w_b" + chrome_name + test_name, 1248 read_byte_b = read_byte;
1230 static_cast<size_t>(io_counters.WriteTransferCount / 1024), 1249 write_byte_b = write_byte;
1231 "kb", false /* not important */); 1250 other_byte_b = other_byte;
1232 PrintResult("other_byte", chrome_name, 1251 total_byte_b = total_byte;
1233 "o_b" + chrome_name + test_name, 1252 } else {
1234 static_cast<size_t>(io_counters.OtherTransferCount / 1024), 1253 read_op_r += read_op;
1235 "kb", false /* not important */); 1254 write_op_r += write_op;
1236 1255 other_op_r += other_op;
1237 total = static_cast<size_t>((io_counters.ReadTransferCount + 1256 total_op_r += total_op;
1238 io_counters.WriteTransferCount + 1257 read_byte_r += read_byte;
1239 io_counters.OtherTransferCount) / 1024); 1258 write_byte_r += write_byte;
1240 PrintResult("total_byte", chrome_name, 1259 other_byte_r += other_byte;
1241 "IO_b" + chrome_name + test_name, 1260 total_byte_r += total_byte;
1242 total, "kb", true /* important */); 1261 }
1243 } 1262 }
1244 1263
1245 base::CloseProcessHandle(process_handle); 1264 base::CloseProcessHandle(process_handle);
1246 } 1265 }
1266
1267 std::string t_name(test_name);
1268 PrintResult("read_op_b", "", "r_op_b" + t_name, read_op_b, "", false);
1269 PrintResult("write_op_b", "", "w_op_b" + t_name, write_op_b, "", false);
1270 PrintResult("other_op_b", "", "o_op_b" + t_name, other_op_b, "", false);
1271 PrintResult("total_op_b", "", "IO_op_b" + t_name, total_op_b, "", true);
1272
1273 PrintResult("read_byte_b", "", "r_b" + t_name, read_byte_b, "kb", false);
1274 PrintResult("write_byte_b", "", "w_b" + t_name, write_byte_b, "kb", false);
1275 PrintResult("other_byte_b", "", "o_b" + t_name, other_byte_b, "kb", false);
1276 PrintResult("total_byte_b", "", "IO_b" + t_name, total_byte_b, "kb", true);
1277
1278 PrintResult("read_op_r", "", "r_op_r" + t_name, read_op_r, "", false);
1279 PrintResult("write_op_r", "", "w_op_r" + t_name, write_op_r, "", false);
1280 PrintResult("other_op_r", "", "o_op_r" + t_name, other_op_r, "", false);
1281 PrintResult("total_op_r", "", "IO_op_r" + t_name, total_op_r, "", true);
1282
1283 PrintResult("read_byte_r", "", "r_r" + t_name, read_byte_r, "kb", false);
1284 PrintResult("write_byte_r", "", "w_r" + t_name, write_byte_r, "kb", false);
1285 PrintResult("other_byte_r", "", "o_r" + t_name, other_byte_r, "kb", false);
1286 PrintResult("total_byte_r", "", "IO_r" + t_name, total_byte_r, "kb", true);
1247 } 1287 }
1248 1288
1249 void UITest::PrintMemoryUsageInfo(const char* test_name, FilePath data_dir) { 1289 void UITest::PrintMemoryUsageInfo(const char* test_name, FilePath data_dir) {
1250 int browser_process_pid = ChromeBrowserProcessId(data_dir); 1290 int browser_process_pid = ChromeBrowserProcessId(data_dir);
1251 ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir)); 1291 ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
1252 1292
1253 #if !defined(OS_MACOSX) 1293 size_t browser_virtual_size = 0;
1294 size_t browser_working_set_size = 0;
1295 size_t renderer_virtual_size = 0;
1296 size_t renderer_working_set_size = 0;
1297 size_t total_virtual_size = 0;
1298 size_t total_working_set_size = 0;
1299 #if defined(OS_WIN)
1300 size_t browser_peak_virtual_size = 0;
1301 size_t browser_peak_working_set_size = 0;
1302 size_t renderer_total_peak_virtual_size = 0;
1303 size_t renderer_total_peak_working_set_size = 0;
1304 size_t renderer_single_peak_virtual_size = 0;
1305 size_t renderer_single_peak_working_set_size = 0;
1306 #endif
1307
1254 ChromeProcessList::const_iterator it; 1308 ChromeProcessList::const_iterator it;
1255 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) { 1309 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
1256 base::ProcessHandle process_handle; 1310 base::ProcessHandle process_handle;
1257 if (!base::OpenPrivilegedProcessHandle(*it, &process_handle)) { 1311 if (!base::OpenPrivilegedProcessHandle(*it, &process_handle)) {
1258 NOTREACHED(); 1312 NOTREACHED();
1259 return; 1313 return;
1260 } 1314 }
1261 1315
1262 scoped_ptr<base::ProcessMetrics> process_metrics( 1316 // TODO(sgk): if/when base::ProcessMetrics returns real stats on mac:
1263 base::ProcessMetrics::CreateProcessMetrics(process_handle)); 1317 //scoped_ptr<base::ProcessMetrics> process_metrics(
1318 // base::ProcessMetrics::CreateProcessMetrics(process_handle));
1319 scoped_ptr<ChromeTestProcessMetrics> process_metrics(
1320 ChromeTestProcessMetrics::CreateProcessMetrics(process_handle));
1264 1321
1265 std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r"; 1322 size_t current_virtual_size = process_metrics->GetPagefileUsage();
1323 size_t current_working_set_size = process_metrics->GetWorkingSetSize();
1266 1324
1267 std::string trace_name(test_name); 1325 if (*it == browser_process_pid) {
1326 browser_virtual_size = current_virtual_size;
1327 browser_working_set_size = current_working_set_size;
1328 } else {
1329 renderer_virtual_size += current_virtual_size;
1330 renderer_working_set_size += current_working_set_size;
1331 }
1332 total_virtual_size += current_virtual_size;
1333 total_working_set_size += current_working_set_size;
1334
1268 #if defined(OS_WIN) 1335 #if defined(OS_WIN)
1269 PrintResult("vm_peak", chrome_name, 1336 size_t peak_virtual_size = process_metrics->GetPeakPagefileUsage();
1270 "vm_pk" + chrome_name + trace_name, 1337 size_t peak_working_set_size = process_metrics->GetPeakWorkingSetSize();
1271 process_metrics->GetPeakPagefileUsage(), "bytes", 1338 if (*it == browser_process_pid) {
1272 true /* important */); 1339 browser_peak_virtual_size = peak_virtual_size;
1273 PrintResult("vm_final", chrome_name, 1340 browser_peak_working_set_size = peak_working_set_size;
1274 "vm_f" + chrome_name + trace_name, 1341 } else {
1275 process_metrics->GetPagefileUsage(), "bytes", 1342 if (peak_virtual_size > renderer_single_peak_virtual_size) {
1276 false /* not important */); 1343 renderer_single_peak_virtual_size = peak_virtual_size;
1277 PrintResult("ws_peak", chrome_name, 1344 }
1278 "ws_pk" + chrome_name + trace_name, 1345 if (peak_working_set_size > renderer_single_peak_working_set_size) {
1279 process_metrics->GetPeakWorkingSetSize(), "bytes", 1346 renderer_single_peak_working_set_size = peak_working_set_size;
1280 true /* important */); 1347 }
1281 PrintResult("ws_final", chrome_name, 1348 renderer_total_peak_virtual_size += peak_virtual_size;
1282 "ws_f" + chrome_name + trace_name, 1349 renderer_total_peak_working_set_size += peak_working_set_size;
1283 process_metrics->GetWorkingSetSize(), "bytes", 1350 }
1284 false /* not important */);
1285 #elif defined(OS_LINUX)
1286 PrintResult("vm_size_final", chrome_name,
1287 "vm_size_f" + chrome_name + trace_name,
1288 process_metrics->GetPagefileUsage(), "bytes",
1289 true /* important */);
1290 PrintResult("vm_rss_final", chrome_name,
1291 "vm_rss_f" + chrome_name + trace_name,
1292 process_metrics->GetWorkingSetSize(), "bytes",
1293 true /* important */);
1294 #else
1295 NOTIMPLEMENTED();
1296 #endif 1351 #endif
1352
1297 base::CloseProcessHandle(process_handle); 1353 base::CloseProcessHandle(process_handle);
1298 } 1354 }
1299 1355
1300 #else // !defined(OS_MACOSX) 1356 std::string trace_name(test_name);
1357 #if defined(OS_WIN)
1358 PrintResult("vm_peak_b", "", "vm_pk_b" + trace_name,
1359 browser_peak_virtual_size, "bytes",
1360 true /* important */);
1361 PrintResult("ws_peak_b", "", "ws_pk_b" + trace_name,
1362 browser_peak_working_set_size, "bytes",
1363 true /* important */);
1364 PrintResult("vm_peak_r", "", "vm_pk_r" + trace_name,
1365 renderer_total_peak_virtual_size, "bytes",
1366 true /* important */);
1367 PrintResult("ws_peak_r", "", "ws_pk_r" + trace_name,
1368 renderer_total_peak_working_set_size, "bytes",
1369 true /* important */);
1370 PrintResult("vm_single_peak_r", "", "vm_spk_r" + trace_name,
1371 renderer_single_peak_virtual_size, "bytes",
1372 true /* important */);
1373 PrintResult("ws_single_peak_r", "", "ws_spk_r" + trace_name,
1374 renderer_single_peak_working_set_size, "bytes",
1375 true /* important */);
1301 1376
1302 // There is no way to get memory info from one process on another process 1377 PrintResult("vm_final_b", "", "vm_f_b" + trace_name,
1303 // without privileges, this means the base methods for doing this can't be 1378 browser_virtual_size, "bytes",
1304 // made to work. Instead we use a helper that invokes ps to collect the 1379 false /* not important */);
1305 // data so we have it for the unittest. 1380 PrintResult("ws_final_b", "", "ws_f_b" + trace_name,
1306 1381 browser_working_set_size, "bytes",
1307 MacChromeProcessInfoList process_infos( 1382 false /* not important */);
1308 GetRunningMacProcessInfo(chrome_processes)); 1383 PrintResult("vm_final_r", "", "vm_f_r" + trace_name,
1309 MacChromeProcessInfoList::const_iterator it; 1384 renderer_virtual_size, "bytes",
1310 for (it = process_infos.begin(); it != process_infos.end(); ++it) { 1385 false /* not important */);
1311 const MacChromeProcessInfo &process_info = *it; 1386 PrintResult("ws_final_r", "", "ws_f_r" + trace_name,
1312 1387 renderer_working_set_size, "bytes",
1313 std::string chrome_name = 1388 false /* not important */);
1314 (process_info.pid == browser_process_pid) ? "_b" : "_r"; 1389 PrintResult("vm_final_t", "", "vm_f_t" + trace_name,
1315 std::string trace_name(test_name); 1390 total_virtual_size, "bytes",
1316 1391 false /* not important */);
1317 PrintResult("vm_size_final", chrome_name, 1392 PrintResult("ws_final_t", "", "ws_f_t" + trace_name,
1318 "vm_size_f" + chrome_name + trace_name, 1393 total_working_set_size, "bytes",
1319 static_cast<size_t>(process_info.vsz_in_kb) * 1024, "bytes", 1394 false /* not important */);
1320 true /* important */); 1395 #elif defined(OS_LINUX) || defined(OS_MACOSX)
1321 PrintResult("vm_rss_final", chrome_name, 1396 PrintResult("vm_size_final_b", "", "vm_size_f_b" + trace_name,
1322 "vm_rss_f" + chrome_name + trace_name, 1397 browser_virtual_size, "bytes",
1323 static_cast<size_t>(process_info.rsz_in_kb) * 1024, "bytes", 1398 true /* important */);
1324 true /* important */); 1399 PrintResult("vm_rss_final_b", "", "vm_rss_f_b" + trace_name,
1325 } 1400 browser_working_set_size, "bytes",
1326 1401 true /* important */);
1327 #endif // !defined(OS_MACOSX) 1402 PrintResult("vm_size_final_r", "", "vm_size_f_r" + trace_name,
1403 renderer_virtual_size, "bytes",
1404 true /* important */);
1405 PrintResult("vm_rss_final_r", "", "vm_rss_f_r" + trace_name,
1406 renderer_working_set_size, "bytes",
1407 true /* important */);
1408 PrintResult("vm_size_final_t", "", "vm_size_f_t" + trace_name,
1409 total_virtual_size, "bytes",
1410 true /* important */);
1411 PrintResult("vm_rss_final_t", "", "vm_rss_f_t" + trace_name,
1412 total_working_set_size, "bytes",
1413 true /* important */);
1414 #else
1415 NOTIMPLEMENTED();
1416 #endif
1417 PrintResult("processes", "", "proc_" + trace_name,
1418 chrome_processes.size(), "",
1419 false /* not important */);
1328 } 1420 }
1329 1421
1330 void UITest::PrintSystemCommitCharge(const char* test_name, size_t charge) { 1422 void UITest::PrintSystemCommitCharge(const char* test_name, size_t charge) {
1331 std::string trace_name(test_name); 1423 std::string trace_name(test_name);
1332 PrintResult("commit_charge", "", "cc" + trace_name, charge, "kb", 1424 PrintResult("commit_charge", "", "cc" + trace_name, charge, "kb",
1333 true /* important */); 1425 false /* important */);
1334 } 1426 }
OLDNEW
« no previous file with comments | « chrome/test/memory_test/memory_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698