OLD | NEW |
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/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } // namespace | 47 } // namespace |
48 | 48 |
49 namespace perf_test { | 49 namespace perf_test { |
50 | 50 |
51 void PrintResult(const std::string& measurement, | 51 void PrintResult(const std::string& measurement, |
52 const std::string& modifier, | 52 const std::string& modifier, |
53 const std::string& trace, | 53 const std::string& trace, |
54 size_t value, | 54 size_t value, |
55 const std::string& units, | 55 const std::string& units, |
56 bool important) { | 56 bool important) { |
57 PrintResultsImpl(measurement, modifier, trace, base::UintToString(value), | 57 PrintResultsImpl(measurement, |
58 "", "", units, important); | 58 modifier, |
| 59 trace, |
| 60 base::UintToString(value), |
| 61 std::string(), |
| 62 std::string(), |
| 63 units, |
| 64 important); |
59 } | 65 } |
60 | 66 |
61 void AppendResult(std::string& output, | 67 void AppendResult(std::string& output, |
62 const std::string& measurement, | 68 const std::string& measurement, |
63 const std::string& modifier, | 69 const std::string& modifier, |
64 const std::string& trace, | 70 const std::string& trace, |
65 size_t value, | 71 size_t value, |
66 const std::string& units, | 72 const std::string& units, |
67 bool important) { | 73 bool important) { |
68 output += ResultsToString(measurement, modifier, trace, | 74 output += ResultsToString(measurement, |
| 75 modifier, |
| 76 trace, |
69 base::UintToString(value), | 77 base::UintToString(value), |
70 "", "", units, important); | 78 std::string(), |
| 79 std::string(), |
| 80 units, |
| 81 important); |
71 } | 82 } |
72 | 83 |
73 void PrintResult(const std::string& measurement, | 84 void PrintResult(const std::string& measurement, |
74 const std::string& modifier, | 85 const std::string& modifier, |
75 const std::string& trace, | 86 const std::string& trace, |
76 const std::string& value, | 87 const std::string& value, |
77 const std::string& units, | 88 const std::string& units, |
78 bool important) { | 89 bool important) { |
79 PrintResultsImpl(measurement, modifier, trace, value, "", "", units, | 90 PrintResultsImpl(measurement, |
| 91 modifier, |
| 92 trace, |
| 93 value, |
| 94 std::string(), |
| 95 std::string(), |
| 96 units, |
80 important); | 97 important); |
81 } | 98 } |
82 | 99 |
83 void AppendResult(std::string& output, | 100 void AppendResult(std::string& output, |
84 const std::string& measurement, | 101 const std::string& measurement, |
85 const std::string& modifier, | 102 const std::string& modifier, |
86 const std::string& trace, | 103 const std::string& trace, |
87 const std::string& value, | 104 const std::string& value, |
88 const std::string& units, | 105 const std::string& units, |
89 bool important) { | 106 bool important) { |
90 output += ResultsToString(measurement, modifier, trace, value, "", "", units, | 107 output += ResultsToString(measurement, |
| 108 modifier, |
| 109 trace, |
| 110 value, |
| 111 std::string(), |
| 112 std::string(), |
| 113 units, |
91 important); | 114 important); |
92 } | 115 } |
93 | 116 |
94 void PrintResultMeanAndError(const std::string& measurement, | 117 void PrintResultMeanAndError(const std::string& measurement, |
95 const std::string& modifier, | 118 const std::string& modifier, |
96 const std::string& trace, | 119 const std::string& trace, |
97 const std::string& mean_and_error, | 120 const std::string& mean_and_error, |
98 const std::string& units, | 121 const std::string& units, |
99 bool important) { | 122 bool important) { |
100 PrintResultsImpl(measurement, modifier, trace, mean_and_error, | 123 PrintResultsImpl(measurement, modifier, trace, mean_and_error, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 write_byte_r += write_byte; | 249 write_byte_r += write_byte; |
227 other_byte_r += other_byte; | 250 other_byte_r += other_byte; |
228 total_byte_r += total_byte; | 251 total_byte_r += total_byte; |
229 } | 252 } |
230 } | 253 } |
231 | 254 |
232 base::CloseProcessHandle(process_handle); | 255 base::CloseProcessHandle(process_handle); |
233 } | 256 } |
234 | 257 |
235 std::string t_name(test_name); | 258 std::string t_name(test_name); |
236 AppendResult(output, "read_op_b", "", "r_op_b" + t_name, read_op_b, "ops", | 259 AppendResult(output, |
| 260 "read_op_b", |
| 261 std::string(), |
| 262 "r_op_b" + t_name, |
| 263 read_op_b, |
| 264 "ops", |
237 false); | 265 false); |
238 AppendResult(output, "write_op_b", "", "w_op_b" + t_name, write_op_b, "ops", | 266 AppendResult(output, |
| 267 "write_op_b", |
| 268 std::string(), |
| 269 "w_op_b" + t_name, |
| 270 write_op_b, |
| 271 "ops", |
239 false); | 272 false); |
240 AppendResult(output, "other_op_b", "", "o_op_b" + t_name, other_op_b, "ops", | 273 AppendResult(output, |
| 274 "other_op_b", |
| 275 std::string(), |
| 276 "o_op_b" + t_name, |
| 277 other_op_b, |
| 278 "ops", |
241 false); | 279 false); |
242 AppendResult(output, "total_op_b", "", "IO_op_b" + t_name, total_op_b, "ops", | 280 AppendResult(output, |
| 281 "total_op_b", |
| 282 std::string(), |
| 283 "IO_op_b" + t_name, |
| 284 total_op_b, |
| 285 "ops", |
243 false); | 286 false); |
244 | 287 |
245 AppendResult(output, "read_byte_b", "", "r_b" + t_name, read_byte_b, "kb", | 288 AppendResult(output, |
| 289 "read_byte_b", |
| 290 std::string(), |
| 291 "r_b" + t_name, |
| 292 read_byte_b, |
| 293 "kb", |
246 false); | 294 false); |
247 AppendResult(output, "write_byte_b", "", "w_b" + t_name, write_byte_b, "kb", | 295 AppendResult(output, |
| 296 "write_byte_b", |
| 297 std::string(), |
| 298 "w_b" + t_name, |
| 299 write_byte_b, |
| 300 "kb", |
248 false); | 301 false); |
249 AppendResult(output, "other_byte_b", "", "o_b" + t_name, other_byte_b, "kb", | 302 AppendResult(output, |
| 303 "other_byte_b", |
| 304 std::string(), |
| 305 "o_b" + t_name, |
| 306 other_byte_b, |
| 307 "kb", |
250 false); | 308 false); |
251 AppendResult(output, "total_byte_b", "", "IO_b" + t_name, total_byte_b, "kb", | 309 AppendResult(output, |
| 310 "total_byte_b", |
| 311 std::string(), |
| 312 "IO_b" + t_name, |
| 313 total_byte_b, |
| 314 "kb", |
252 false); | 315 false); |
253 | 316 |
254 AppendResult(output, "read_op_r", "", "r_op_r" + t_name, read_op_r, "ops", | 317 AppendResult(output, |
| 318 "read_op_r", |
| 319 std::string(), |
| 320 "r_op_r" + t_name, |
| 321 read_op_r, |
| 322 "ops", |
255 false); | 323 false); |
256 AppendResult(output, "write_op_r", "", "w_op_r" + t_name, write_op_r, "ops", | 324 AppendResult(output, |
| 325 "write_op_r", |
| 326 std::string(), |
| 327 "w_op_r" + t_name, |
| 328 write_op_r, |
| 329 "ops", |
257 false); | 330 false); |
258 AppendResult(output, "other_op_r", "", "o_op_r" + t_name, other_op_r, "ops", | 331 AppendResult(output, |
| 332 "other_op_r", |
| 333 std::string(), |
| 334 "o_op_r" + t_name, |
| 335 other_op_r, |
| 336 "ops", |
259 false); | 337 false); |
260 AppendResult(output, "total_op_r", "", "IO_op_r" + t_name, total_op_r, "ops", | 338 AppendResult(output, |
| 339 "total_op_r", |
| 340 std::string(), |
| 341 "IO_op_r" + t_name, |
| 342 total_op_r, |
| 343 "ops", |
261 false); | 344 false); |
262 | 345 |
263 AppendResult(output, "read_byte_r", "", "r_r" + t_name, read_byte_r, "kb", | 346 AppendResult(output, |
| 347 "read_byte_r", |
| 348 std::string(), |
| 349 "r_r" + t_name, |
| 350 read_byte_r, |
| 351 "kb", |
264 false); | 352 false); |
265 AppendResult(output, "write_byte_r", "", "w_r" + t_name, write_byte_r, "kb", | 353 AppendResult(output, |
| 354 "write_byte_r", |
| 355 std::string(), |
| 356 "w_r" + t_name, |
| 357 write_byte_r, |
| 358 "kb", |
266 false); | 359 false); |
267 AppendResult(output, "other_byte_r", "", "o_r" + t_name, other_byte_r, "kb", | 360 AppendResult(output, |
| 361 "other_byte_r", |
| 362 std::string(), |
| 363 "o_r" + t_name, |
| 364 other_byte_r, |
| 365 "kb", |
268 false); | 366 false); |
269 AppendResult(output, "total_byte_r", "", "IO_r" + t_name, total_byte_r, "kb", | 367 AppendResult(output, |
| 368 "total_byte_r", |
| 369 std::string(), |
| 370 "IO_r" + t_name, |
| 371 total_byte_r, |
| 372 "kb", |
270 false); | 373 false); |
271 | 374 |
272 return output; | 375 return output; |
273 } | 376 } |
274 | 377 |
275 void PrintMemoryUsageInfo(const std::string& test_name, | 378 void PrintMemoryUsageInfo(const std::string& test_name, |
276 const ChromeProcessList& chrome_processes, | 379 const ChromeProcessList& chrome_processes, |
277 base::ProcessId browser_pid) { | 380 base::ProcessId browser_pid) { |
278 PrintMemoryUsageInfo(stdout, test_name, chrome_processes, browser_pid); | 381 PrintMemoryUsageInfo(stdout, test_name, chrome_processes, browser_pid); |
279 } | 382 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 AppendResult(output, "ws_final_r", "", "ws_f_r" + trace_name, | 488 AppendResult(output, "ws_final_r", "", "ws_f_r" + trace_name, |
386 renderer_working_set_size, "bytes", | 489 renderer_working_set_size, "bytes", |
387 false /* not important */); | 490 false /* not important */); |
388 AppendResult(output, "vm_final_t", "", "vm_f_t" + trace_name, | 491 AppendResult(output, "vm_final_t", "", "vm_f_t" + trace_name, |
389 total_virtual_size, "bytes", | 492 total_virtual_size, "bytes", |
390 false /* not important */); | 493 false /* not important */); |
391 AppendResult(output, "ws_final_t", "", "ws_f_t" + trace_name, | 494 AppendResult(output, "ws_final_t", "", "ws_f_t" + trace_name, |
392 total_working_set_size, "bytes", | 495 total_working_set_size, "bytes", |
393 false /* not important */); | 496 false /* not important */); |
394 #elif defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_ANDROID) | 497 #elif defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_ANDROID) |
395 AppendResult(output, "vm_size_final_b", "", "vm_size_f_b" + trace_name, | 498 AppendResult(output, |
396 browser_virtual_size, "bytes", | 499 "vm_size_final_b", |
| 500 std::string(), |
| 501 "vm_size_f_b" + trace_name, |
| 502 browser_virtual_size, |
| 503 "bytes", |
397 false /* not important */); | 504 false /* not important */); |
398 AppendResult(output, "vm_rss_final_b", "", "vm_rss_f_b" + trace_name, | 505 AppendResult(output, |
399 browser_working_set_size, "bytes", | 506 "vm_rss_final_b", |
| 507 std::string(), |
| 508 "vm_rss_f_b" + trace_name, |
| 509 browser_working_set_size, |
| 510 "bytes", |
400 false /* not important */); | 511 false /* not important */); |
401 AppendResult(output, "vm_size_final_r", "", "vm_size_f_r" + trace_name, | 512 AppendResult(output, |
402 renderer_virtual_size, "bytes", | 513 "vm_size_final_r", |
| 514 std::string(), |
| 515 "vm_size_f_r" + trace_name, |
| 516 renderer_virtual_size, |
| 517 "bytes", |
403 false /* not important */); | 518 false /* not important */); |
404 AppendResult(output, "vm_rss_final_r", "", "vm_rss_f_r" + trace_name, | 519 AppendResult(output, |
405 renderer_working_set_size, "bytes", | 520 "vm_rss_final_r", |
| 521 std::string(), |
| 522 "vm_rss_f_r" + trace_name, |
| 523 renderer_working_set_size, |
| 524 "bytes", |
406 false /* not important */); | 525 false /* not important */); |
407 AppendResult(output, "vm_size_final_t", "", "vm_size_f_t" + trace_name, | 526 AppendResult(output, |
408 total_virtual_size, "bytes", | 527 "vm_size_final_t", |
| 528 std::string(), |
| 529 "vm_size_f_t" + trace_name, |
| 530 total_virtual_size, |
| 531 "bytes", |
409 false /* not important */); | 532 false /* not important */); |
410 AppendResult(output, "vm_rss_final_t", "", "vm_rss_f_t" + trace_name, | 533 AppendResult(output, |
411 total_working_set_size, "bytes", | 534 "vm_rss_final_t", |
| 535 std::string(), |
| 536 "vm_rss_f_t" + trace_name, |
| 537 total_working_set_size, |
| 538 "bytes", |
412 false /* not important */); | 539 false /* not important */); |
413 #else | 540 #else |
414 NOTIMPLEMENTED(); | 541 NOTIMPLEMENTED(); |
415 #endif | 542 #endif |
416 AppendResult(output, "processes", "", "proc_" + trace_name, | 543 AppendResult(output, |
417 chrome_processes.size(), "count", | 544 "processes", |
| 545 std::string(), |
| 546 "proc_" + trace_name, |
| 547 chrome_processes.size(), |
| 548 "count", |
418 false /* not important */); | 549 false /* not important */); |
419 | 550 |
420 return output; | 551 return output; |
421 } | 552 } |
422 | 553 |
423 void PrintSystemCommitCharge(const std::string& test_name, | 554 void PrintSystemCommitCharge(const std::string& test_name, |
424 size_t charge, | 555 size_t charge, |
425 bool important) { | 556 bool important) { |
426 PrintSystemCommitCharge(stdout, test_name, charge, important); | 557 PrintSystemCommitCharge(stdout, test_name, charge, important); |
427 } | 558 } |
428 | 559 |
429 void PrintSystemCommitCharge(FILE* target, | 560 void PrintSystemCommitCharge(FILE* target, |
430 const std::string& test_name, | 561 const std::string& test_name, |
431 size_t charge, | 562 size_t charge, |
432 bool important) { | 563 bool important) { |
433 fprintf(target, "%s", SystemCommitChargeToString(test_name, charge, | 564 fprintf(target, "%s", SystemCommitChargeToString(test_name, charge, |
434 important).c_str()); | 565 important).c_str()); |
435 } | 566 } |
436 | 567 |
437 std::string SystemCommitChargeToString(const std::string& test_name, | 568 std::string SystemCommitChargeToString(const std::string& test_name, |
438 size_t charge, | 569 size_t charge, |
439 bool important) { | 570 bool important) { |
440 std::string trace_name(test_name); | 571 std::string trace_name(test_name); |
441 std::string output; | 572 std::string output; |
442 AppendResult(output, "commit_charge", "", "cc" + trace_name, charge, "kb", | 573 AppendResult(output, |
| 574 "commit_charge", |
| 575 std::string(), |
| 576 "cc" + trace_name, |
| 577 charge, |
| 578 "kb", |
443 important); | 579 important); |
444 return output; | 580 return output; |
445 } | 581 } |
446 | 582 |
447 } // namespace perf_test | 583 } // namespace perf_test |
OLD | NEW |