OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome_frame/test/perf/chrome_frame_perftest.h" | 4 #include "chrome_frame/test/perf/chrome_frame_perftest.h" |
5 | 5 |
6 #include <atlwin.h> | 6 #include <atlwin.h> |
7 #include <atlhost.h> | 7 #include <atlhost.h> |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 #include <string> | 10 #include <string> |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 size_t commit_size = (end_commit_charge - start_commit_charge_) * 1024; | 651 size_t commit_size = (end_commit_charge - start_commit_charge_) * 1024; |
652 | 652 |
653 std::string trace_name(test_name); | 653 std::string trace_name(test_name); |
654 trace_name.append("_cc"); | 654 trace_name.append("_cc"); |
655 | 655 |
656 PrintResult("commit_charge", "", trace_name, | 656 PrintResult("commit_charge", "", trace_name, |
657 commit_size / 1024, "KB", true /* important */); | 657 commit_size / 1024, "KB", true /* important */); |
658 printf("\n"); | 658 printf("\n"); |
659 } | 659 } |
660 | 660 |
| 661 base::ProcessId chrome_browser_process_id() { |
| 662 base::NamedProcessIterator iter(L"chrome.exe", NULL); |
| 663 const base::ProcessEntry* entry = iter.NextProcessEntry(); |
| 664 if (entry) { |
| 665 return entry->pid(); |
| 666 } |
| 667 return -1; |
| 668 } |
| 669 |
661 ChromeProcessList GetBrowserChildren() { | 670 ChromeProcessList GetBrowserChildren() { |
662 ChromeProcessList list = GetRunningChromeProcesses(browser_process_id()); | 671 ChromeProcessList list = GetRunningChromeProcesses( |
| 672 chrome_browser_process_id()); |
663 ChromeProcessList::iterator browser = | 673 ChromeProcessList::iterator browser = |
664 std::find(list.begin(), list.end(), browser_process_id()); | 674 std::find(list.begin(), list.end(), chrome_browser_process_id()); |
665 if (browser != list.end()) { | 675 if (browser != list.end()) { |
666 list.erase(browser); | 676 list.erase(browser); |
667 } | 677 } |
668 return list; | 678 return list; |
669 } | 679 } |
670 | 680 |
671 void AccountProcessMemoryUsage(DWORD process_id) { | 681 void AccountProcessMemoryUsage(DWORD process_id) { |
672 ProcessMemoryInfo process_memory_info( | 682 ProcessMemoryInfo process_memory_info( |
673 process_id, process_id == browser_process_id(), this); | 683 process_id, process_id == chrome_browser_process_id(), this); |
674 | 684 |
675 ASSERT_TRUE(process_memory_info.GetMemoryConsumptionDetails()); | 685 ASSERT_TRUE(process_memory_info.GetMemoryConsumptionDetails()); |
676 | 686 |
677 memory_consumption_map_[process_id] = process_memory_info; | 687 memory_consumption_map_[process_id] = process_memory_info; |
678 } | 688 } |
679 | 689 |
680 void PrintMemoryUsageInfo(const char* test_name) { | 690 void PrintMemoryUsageInfo(const char* test_name) { |
681 printf("\n"); | 691 printf("\n"); |
682 | 692 |
683 std::string trace_name(test_name); | 693 std::string trace_name(test_name); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 ASSERT_TRUE(chrome_frame_container_ != NULL); | 827 ASSERT_TRUE(chrome_frame_container_ != NULL); |
818 ASSERT_TRUE(!url.empty()); | 828 ASSERT_TRUE(!url.empty()); |
819 chrome_frame_container_->Navigate(url.c_str()); | 829 chrome_frame_container_->Navigate(url.c_str()); |
820 } | 830 } |
821 | 831 |
822 void TestCompleted() { | 832 void TestCompleted() { |
823 // This can get called multiple times if the last url results in a | 833 // This can get called multiple times if the last url results in a |
824 // redirect. | 834 // redirect. |
825 if (!test_completed_) { | 835 if (!test_completed_) { |
826 // Measure memory usage for the browser process. | 836 // Measure memory usage for the browser process. |
827 AccountProcessMemoryUsage(browser_process_id()); | 837 AccountProcessMemoryUsage(chrome_browser_process_id()); |
828 // Measure memory usage for the current process. | 838 // Measure memory usage for the current process. |
829 AccountProcessMemoryUsage(GetCurrentProcessId()); | 839 AccountProcessMemoryUsage(GetCurrentProcessId()); |
830 | 840 |
831 test_completed_ = true; | 841 test_completed_ = true; |
832 EXPECT_TRUE(PostMessage(static_cast<HWND>(*chrome_frame_container_), | 842 EXPECT_TRUE(PostMessage(static_cast<HWND>(*chrome_frame_container_), |
833 WM_CLOSE, 0, 0)); | 843 WM_CLOSE, 0, 0)); |
834 } | 844 } |
835 } | 845 } |
836 | 846 |
837 protected: | 847 protected: |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 PrintPerfTestResults(automation_provider_connect_monitor, kNumCycles, | 1467 PrintPerfTestResults(automation_provider_connect_monitor, kNumCycles, |
1458 "automationproviderconnect"); | 1468 "automationproviderconnect"); |
1459 PrintPerfTestResults(external_tab_navigate_monitor, kNumCycles, | 1469 PrintPerfTestResults(external_tab_navigate_monitor, kNumCycles, |
1460 "externaltabnavigate"); | 1470 "externaltabnavigate"); |
1461 PrintPerfTestResults(renderer_main_monitor, kNumCycles, | 1471 PrintPerfTestResults(renderer_main_monitor, kNumCycles, |
1462 "beginrenderermain"); | 1472 "beginrenderermain"); |
1463 #ifdef NDEBUG | 1473 #ifdef NDEBUG |
1464 PrintPerfTestResults(pre_read_chrome_monitor, kNumCycles, "PreReadImage"); | 1474 PrintPerfTestResults(pre_read_chrome_monitor, kNumCycles, "PreReadImage"); |
1465 #endif // NDEBUG | 1475 #endif // NDEBUG |
1466 } | 1476 } |
OLD | NEW |