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

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

Issue 402052: Prep for printing common memory stats from page_cycler_tests and memory_test:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove commented-out code from previous upload 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/ui/ui_test.h ('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 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 std::string yesterday_str = Int64ToString(yesterday.ToInternalValue()); 1171 std::string yesterday_str = Int64ToString(yesterday.ToInternalValue());
1172 std::string query = StringPrintf( 1172 std::string query = StringPrintf(
1173 "UPDATE segment_usage " 1173 "UPDATE segment_usage "
1174 "SET time_slot = %s " 1174 "SET time_slot = %s "
1175 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);", 1175 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);",
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
1182 void UITest::PrintIOPerfInfo(const char* test_name, FilePath data_dir) {
1183 int browser_process_pid = ChromeBrowserProcessId(data_dir);
1184 ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
1185
1186 ChromeProcessList::const_iterator it;
1187 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
1188 base::ProcessHandle process_handle;
1189 if (!base::OpenPrivilegedProcessHandle(*it, &process_handle)) {
1190 NOTREACHED();
1191 return;
1192 }
1193
1194 scoped_ptr<base::ProcessMetrics> process_metrics(
1195 base::ProcessMetrics::CreateProcessMetrics(process_handle));
1196 IoCounters io_counters;
1197 memset(&io_counters, 0, sizeof(io_counters));
1198
1199 if (process_metrics.get()->GetIOCounters(&io_counters)) {
1200 // Print out IO performance. We assume that the values can be
1201 // converted to size_t (they're reported as ULONGLONG, 64-bit numbers).
1202 std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r";
1203
1204 PrintResult("read_op", chrome_name,
1205 "r_op" + chrome_name + test_name,
1206 static_cast<size_t>(io_counters.ReadOperationCount), "",
1207 false /* not important */);
1208 PrintResult("write_op", chrome_name,
1209 "w_op" + chrome_name + test_name,
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
1217 size_t total = static_cast<size_t>(io_counters.ReadOperationCount +
1218 io_counters.WriteOperationCount +
1219 io_counters.OtherOperationCount);
1220 PrintResult("total_op", chrome_name,
1221 "IO_op" + chrome_name + test_name,
1222 total, "", true /* important */);
1223
1224 PrintResult("read_byte", chrome_name,
1225 "r_b" + chrome_name + test_name,
1226 static_cast<size_t>(io_counters.ReadTransferCount / 1024),
1227 "kb", false /* not important */);
1228 PrintResult("write_byte", chrome_name,
1229 "w_b" + chrome_name + test_name,
1230 static_cast<size_t>(io_counters.WriteTransferCount / 1024),
1231 "kb", false /* not important */);
1232 PrintResult("other_byte", chrome_name,
1233 "o_b" + chrome_name + test_name,
1234 static_cast<size_t>(io_counters.OtherTransferCount / 1024),
1235 "kb", false /* not important */);
1236
1237 total = static_cast<size_t>((io_counters.ReadTransferCount +
1238 io_counters.WriteTransferCount +
1239 io_counters.OtherTransferCount) / 1024);
1240 PrintResult("total_byte", chrome_name,
1241 "IO_b" + chrome_name + test_name,
1242 total, "kb", true /* important */);
1243 }
1244
1245 base::CloseProcessHandle(process_handle);
1246 }
1247 }
1248
1249 void UITest::PrintMemoryUsageInfo(const char* test_name, FilePath data_dir) {
1250 int browser_process_pid = ChromeBrowserProcessId(data_dir);
1251 ChromeProcessList chrome_processes(GetRunningChromeProcesses(data_dir));
1252
1253 #if !defined(OS_MACOSX)
1254 ChromeProcessList::const_iterator it;
1255 for (it = chrome_processes.begin(); it != chrome_processes.end(); ++it) {
1256 base::ProcessHandle process_handle;
1257 if (!base::OpenPrivilegedProcessHandle(*it, &process_handle)) {
1258 NOTREACHED();
1259 return;
1260 }
1261
1262 scoped_ptr<base::ProcessMetrics> process_metrics(
1263 base::ProcessMetrics::CreateProcessMetrics(process_handle));
1264
1265 std::string chrome_name = (*it == browser_process_pid) ? "_b" : "_r";
1266
1267 std::string trace_name(test_name);
1268 #if defined(OS_WIN)
1269 PrintResult("vm_peak", chrome_name,
1270 "vm_pk" + chrome_name + trace_name,
1271 process_metrics->GetPeakPagefileUsage(), "bytes",
1272 true /* important */);
1273 PrintResult("vm_final", chrome_name,
1274 "vm_f" + chrome_name + trace_name,
1275 process_metrics->GetPagefileUsage(), "bytes",
1276 false /* not important */);
1277 PrintResult("ws_peak", chrome_name,
1278 "ws_pk" + chrome_name + trace_name,
1279 process_metrics->GetPeakWorkingSetSize(), "bytes",
1280 true /* important */);
1281 PrintResult("ws_final", chrome_name,
1282 "ws_f" + chrome_name + trace_name,
1283 process_metrics->GetWorkingSetSize(), "bytes",
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
1297 base::CloseProcessHandle(process_handle);
1298 }
1299
1300 #else // !defined(OS_MACOSX)
1301
1302 // There is no way to get memory info from one process on another process
1303 // without privileges, this means the base methods for doing this can't be
1304 // made to work. Instead we use a helper that invokes ps to collect the
1305 // data so we have it for the unittest.
1306
1307 MacChromeProcessInfoList process_infos(
1308 GetRunningMacProcessInfo(chrome_processes));
1309 MacChromeProcessInfoList::const_iterator it;
1310 for (it = process_infos.begin(); it != process_infos.end(); ++it) {
1311 const MacChromeProcessInfo &process_info = *it;
1312
1313 std::string chrome_name =
1314 (process_info.pid == browser_process_pid) ? "_b" : "_r";
1315 std::string trace_name(test_name);
1316
1317 PrintResult("vm_size_final", chrome_name,
1318 "vm_size_f" + chrome_name + trace_name,
1319 static_cast<size_t>(process_info.vsz_in_kb) * 1024, "bytes",
1320 true /* important */);
1321 PrintResult("vm_rss_final", chrome_name,
1322 "vm_rss_f" + chrome_name + trace_name,
1323 static_cast<size_t>(process_info.rsz_in_kb) * 1024, "bytes",
1324 true /* important */);
1325 }
1326
1327 #endif // !defined(OS_MACOSX)
1328 }
1329
1330 void UITest::PrintSystemCommitCharge(const char* test_name, size_t charge) {
1331 std::string trace_name(test_name);
1332 PrintResult("commit_charge", "", "cc" + trace_name, charge, "kb",
1333 true /* important */);
1334 }
OLDNEW
« no previous file with comments | « chrome/test/ui/ui_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698