OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 | 11 |
12 #include "base/debug/trace_event_win.h" | 12 #include "base/debug/trace_event_win.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/process_util.h" | 17 #include "base/process_util.h" |
18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
19 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
20 #include "base/threading/platform_thread.h" | 20 #include "base/threading/platform_thread.h" |
21 #include "base/time.h" | 21 #include "base/time.h" |
22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
23 #include "base/win/event_trace_consumer.h" | 23 #include "base/win/event_trace_consumer.h" |
24 #include "base/win/event_trace_controller.h" | 24 #include "base/win/event_trace_controller.h" |
25 #include "base/win/registry.h" | 25 #include "base/win/registry.h" |
26 #include "base/win/scoped_bstr.h" | 26 #include "base/win/scoped_bstr.h" |
27 #include "base/win/scoped_comptr.h" | 27 #include "base/win/scoped_comptr.h" |
28 #include "base/win/scoped_variant.h" | 28 #include "base/win/scoped_variant.h" |
| 29 #include "chrome/app/image_pre_reader_win.h" |
29 #include "chrome/common/chrome_constants.h" | 30 #include "chrome/common/chrome_constants.h" |
30 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
31 #include "chrome/common/chrome_paths_internal.h" | 32 #include "chrome/common/chrome_paths_internal.h" |
32 #include "chrome/test/base/chrome_process_util.h" | 33 #include "chrome/test/base/chrome_process_util.h" |
33 #include "chrome/test/perf/perf_test.h" | 34 #include "chrome/test/perf/perf_test.h" |
34 #include "chrome/test/ui/ui_perf_test.h" | 35 #include "chrome/test/ui/ui_perf_test.h" |
35 #include "chrome_frame/chrome_tab.h" | 36 #include "chrome_frame/chrome_tab.h" |
36 #include "chrome_frame/test_utils.h" | 37 #include "chrome_frame/test_utils.h" |
37 #include "chrome_frame/utils.h" | 38 #include "chrome_frame/utils.h" |
38 | 39 |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 wnd.CreateControl(true); | 402 wnd.CreateControl(true); |
402 module.RunMessageLoop(); | 403 module.RunMessageLoop(); |
403 *end_time = TimeTicks::Now(); | 404 *end_time = TimeTicks::Now(); |
404 } | 405 } |
405 }; | 406 }; |
406 | 407 |
407 // This class measures the load time of chrome and chrome frame binaries | 408 // This class measures the load time of chrome and chrome frame binaries |
408 class ChromeFrameBinariesLoadTest : public ChromeFrameStartupTestActiveX { | 409 class ChromeFrameBinariesLoadTest : public ChromeFrameStartupTestActiveX { |
409 static const size_t kStepSize = 4 * 1024; | 410 static const size_t kStepSize = 4 * 1024; |
410 public: | 411 public: |
| 412 enum PreReadType { |
| 413 kPreReadNone, |
| 414 kPreReadPartial, |
| 415 kPreReadFull |
| 416 }; |
| 417 |
411 ChromeFrameBinariesLoadTest() | 418 ChromeFrameBinariesLoadTest() |
412 : pre_read_(false), | 419 : pre_read_type_(kPreReadNone), |
413 step_size_(kStepSize), | 420 step_size_(kStepSize), |
414 bytes_to_read_(0) {} | 421 bytes_to_read_(0), |
| 422 percentage_to_preread_(25) {} |
415 | 423 |
416 protected: | 424 protected: |
417 virtual void RunStartupTestImpl(TimeTicks* start_time, | 425 virtual void RunStartupTestImpl(TimeTicks* start_time, |
418 TimeTicks* end_time) { | 426 TimeTicks* end_time) { |
419 *start_time = TimeTicks::Now(); | 427 *start_time = TimeTicks::Now(); |
420 | 428 |
421 if (pre_read_) { | 429 if (pre_read_type_ == kPreReadFull) { |
422 EXPECT_TRUE(file_util::PreReadImage(chrome_exe_.value().c_str(), | 430 EXPECT_TRUE(ImagePreReader::PreReadImage(chrome_exe_.value().c_str(), |
423 bytes_to_read_, | 431 bytes_to_read_, |
424 step_size_)); | 432 step_size_)); |
425 EXPECT_TRUE(file_util::PreReadImage(chrome_dll_.value().c_str(), | 433 EXPECT_TRUE(ImagePreReader::PreReadImage(chrome_dll_.value().c_str(), |
426 bytes_to_read_, | 434 bytes_to_read_, |
427 step_size_)); | 435 step_size_)); |
| 436 } else if (pre_read_type_ == kPreReadPartial) { |
| 437 EXPECT_TRUE( |
| 438 ImagePreReader::PartialPreReadImage(chrome_exe_.value().c_str(), |
| 439 percentage_to_preread_, |
| 440 step_size_)); |
| 441 EXPECT_TRUE( |
| 442 ImagePreReader::PartialPreReadImage(chrome_dll_.value().c_str(), |
| 443 percentage_to_preread_, |
| 444 step_size_)); |
428 } | 445 } |
429 | 446 |
430 HMODULE chrome_exe = LoadLibrary(chrome_exe_.value().c_str()); | 447 HMODULE chrome_exe = LoadLibrary(chrome_exe_.value().c_str()); |
431 EXPECT_TRUE(chrome_exe != NULL); | 448 EXPECT_TRUE(chrome_exe != NULL); |
432 | 449 |
433 HMODULE chrome_dll = LoadLibrary(chrome_dll_.value().c_str()); | 450 HMODULE chrome_dll = LoadLibrary(chrome_dll_.value().c_str()); |
434 EXPECT_TRUE(chrome_dll != NULL); | 451 EXPECT_TRUE(chrome_dll != NULL); |
435 | 452 |
436 *end_time = TimeTicks::Now(); | 453 *end_time = TimeTicks::Now(); |
437 | 454 |
438 FreeLibrary(chrome_exe); | 455 FreeLibrary(chrome_exe); |
439 FreeLibrary(chrome_dll); | 456 FreeLibrary(chrome_dll); |
440 } | 457 } |
441 | 458 |
442 bool pre_read_; | 459 PreReadType pre_read_type_; |
443 size_t bytes_to_read_; | 460 size_t bytes_to_read_; |
444 size_t step_size_; | 461 size_t step_size_; |
| 462 uint8 percentage_to_preread_; |
445 }; | 463 }; |
446 | 464 |
447 // This class provides functionality to run the startup performance test for | 465 // This class provides functionality to run the startup performance test for |
448 // the ChromeFrame ActiveX against a reference build. At this point we only run | 466 // the ChromeFrame ActiveX against a reference build. At this point we only run |
449 // this test in warm mode. | 467 // this test in warm mode. |
450 class ChromeFrameStartupTestActiveXReference | 468 class ChromeFrameStartupTestActiveXReference |
451 : public ChromeFrameStartupTestActiveX { | 469 : public ChromeFrameStartupTestActiveX { |
452 public: | 470 public: |
453 // override the browser directory to use the reference build instead. | 471 // override the browser directory to use the reference build instead. |
454 virtual void SetUp() { | 472 virtual void SetUp() { |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 | 937 |
920 *start_time = TimeTicks::Now(); | 938 *start_time = TimeTicks::Now(); |
921 HRESULT hr = host.CreateControl(L"AgControl.AgControl"); | 939 HRESULT hr = host.CreateControl(L"AgControl.AgControl"); |
922 EXPECT_HRESULT_SUCCEEDED(hr); | 940 EXPECT_HRESULT_SUCCEEDED(hr); |
923 *end_time = TimeTicks::Now(); | 941 *end_time = TimeTicks::Now(); |
924 | 942 |
925 ReleaseHostComReferences(host); | 943 ReleaseHostComReferences(host); |
926 } | 944 } |
927 }; | 945 }; |
928 | 946 |
| 947 // TODO(rogerm): Flesh out the *PreReadImage* tests to validate an observed |
| 948 // change in paging behaviour between raw loading and pre-reading. |
| 949 |
| 950 // TODO(rogerm): Add checks to the *PreReadImage* tests to validate the |
| 951 // handling of invalid pe files and paths as input. |
| 952 |
| 953 TEST(ImagePreReader, PreReadImage) { |
| 954 FilePath current_exe; |
| 955 ASSERT_TRUE(PathService::Get(base::FILE_EXE, ¤t_exe)); |
| 956 |
| 957 int64 file_size_64 = 0; |
| 958 ASSERT_TRUE(file_util::GetFileSize(current_exe, &file_size_64)); |
| 959 ASSERT_TRUE(file_size_64 < std::numeric_limits<std::size_t>::max()); |
| 960 size_t file_size = static_cast<size_t>(file_size_64); |
| 961 |
| 962 const wchar_t* module_path = current_exe.value().c_str(); |
| 963 const size_t kStepSize = 2 * 1024 * 1024; |
| 964 |
| 965 ASSERT_TRUE( |
| 966 ImagePreReader::PreReadImage(module_path, 0, kStepSize)); |
| 967 ASSERT_TRUE( |
| 968 ImagePreReader::PreReadImage(module_path, file_size / 4, kStepSize)); |
| 969 ASSERT_TRUE( |
| 970 ImagePreReader::PreReadImage(module_path, file_size / 2, kStepSize)); |
| 971 ASSERT_TRUE( |
| 972 ImagePreReader::PreReadImage(module_path, file_size, kStepSize)); |
| 973 ASSERT_TRUE( |
| 974 ImagePreReader::PreReadImage(module_path, file_size * 2, kStepSize)); |
| 975 } |
| 976 |
| 977 TEST(ImagePreReader, PartialPreReadImage) { |
| 978 FilePath current_exe; |
| 979 ASSERT_TRUE(PathService::Get(base::FILE_EXE, ¤t_exe)); |
| 980 |
| 981 const wchar_t* module_path = current_exe.value().c_str(); |
| 982 const size_t kStepSize = 2 * 1024 * 1024; |
| 983 |
| 984 ASSERT_TRUE( |
| 985 ImagePreReader::PartialPreReadImage(module_path, 0, kStepSize)); |
| 986 ASSERT_TRUE( |
| 987 ImagePreReader::PartialPreReadImage(module_path, 25, kStepSize)); |
| 988 ASSERT_TRUE( |
| 989 ImagePreReader::PartialPreReadImage(module_path, 50, kStepSize)); |
| 990 ASSERT_TRUE( |
| 991 ImagePreReader::PartialPreReadImage(module_path, 100, kStepSize)); |
| 992 ASSERT_TRUE( |
| 993 ImagePreReader::PartialPreReadImage(module_path, 150, kStepSize)); |
| 994 } |
| 995 |
| 996 TEST(ImagePreReader, PartialPreReadImageOnDisk) { |
| 997 FilePath current_exe; |
| 998 ASSERT_TRUE(PathService::Get(base::FILE_EXE, ¤t_exe)); |
| 999 |
| 1000 const wchar_t* module_path = current_exe.value().c_str(); |
| 1001 const size_t kChunkSize = 2 * 1024 * 1024; |
| 1002 |
| 1003 ASSERT_TRUE( |
| 1004 ImagePreReader::PartialPreReadImageOnDisk(module_path, 0, kChunkSize)); |
| 1005 ASSERT_TRUE( |
| 1006 ImagePreReader::PartialPreReadImageOnDisk(module_path, 25, kChunkSize)); |
| 1007 ASSERT_TRUE( |
| 1008 ImagePreReader::PartialPreReadImageOnDisk(module_path, 50, kChunkSize)); |
| 1009 ASSERT_TRUE( |
| 1010 ImagePreReader::PartialPreReadImageOnDisk(module_path, 100, kChunkSize)); |
| 1011 ASSERT_TRUE( |
| 1012 ImagePreReader::PartialPreReadImageOnDisk(module_path, 150, kChunkSize)); |
| 1013 } |
| 1014 |
| 1015 TEST(ImagePreReader, PartialPreReadImageInMemory) { |
| 1016 FilePath current_exe; |
| 1017 ASSERT_TRUE(PathService::Get(base::FILE_EXE, ¤t_exe)); |
| 1018 const wchar_t* module_path = current_exe.value().c_str(); |
| 1019 |
| 1020 ASSERT_TRUE( |
| 1021 ImagePreReader::PartialPreReadImageInMemory(module_path, 0)); |
| 1022 ASSERT_TRUE( |
| 1023 ImagePreReader::PartialPreReadImageInMemory(module_path, 25)); |
| 1024 ASSERT_TRUE( |
| 1025 ImagePreReader::PartialPreReadImageInMemory(module_path, 50)); |
| 1026 ASSERT_TRUE( |
| 1027 ImagePreReader::PartialPreReadImageInMemory(module_path, 100)); |
| 1028 ASSERT_TRUE( |
| 1029 ImagePreReader::PartialPreReadImageInMemory(module_path, 150)); |
| 1030 } |
| 1031 |
929 TEST(ChromeFramePerf, DISABLED_HostActiveX) { | 1032 TEST(ChromeFramePerf, DISABLED_HostActiveX) { |
930 // TODO(stoyan): Create a low integrity level thread && perform the test there | 1033 // TODO(stoyan): Create a low integrity level thread && perform the test there |
931 SimpleModule module; | 1034 SimpleModule module; |
932 AtlAxWinInit(); | 1035 AtlAxWinInit(); |
933 CComObjectStackEx<ChromeFrameActiveXContainerPerf> wnd; | 1036 CComObjectStackEx<ChromeFrameActiveXContainerPerf> wnd; |
934 wnd.CreateChromeFrameWindow("http://www.google.com"); | 1037 wnd.CreateChromeFrameWindow("http://www.google.com"); |
935 wnd.CreateControl(true); | 1038 wnd.CreateControl(true); |
936 module.RunMessageLoop(); | 1039 module.RunMessageLoop(); |
937 } | 1040 } |
938 | 1041 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 | 1085 |
983 TEST_F(ChromeFrameBinariesLoadTest, PerfCold) { | 1086 TEST_F(ChromeFrameBinariesLoadTest, PerfCold) { |
984 FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_}; | 1087 FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_}; |
985 RunStartupTest("binary_load_cold", "t", "", true /* cold */, | 1088 RunStartupTest("binary_load_cold", "t", "", true /* cold */, |
986 arraysize(binaries_to_evict), binaries_to_evict, | 1089 arraysize(binaries_to_evict), binaries_to_evict, |
987 false /* not important */, false); | 1090 false /* not important */, false); |
988 } | 1091 } |
989 | 1092 |
990 TEST_F(ChromeFrameBinariesLoadTest, PerfColdPreRead) { | 1093 TEST_F(ChromeFrameBinariesLoadTest, PerfColdPreRead) { |
991 FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_}; | 1094 FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_}; |
992 pre_read_ = true; | 1095 pre_read_type_ = kPreReadFull; |
993 RunStartupTest("binary_load_cold_preread", "t", "", true /* cold */, | 1096 RunStartupTest("binary_load_cold_preread", "t", "", true /* cold */, |
994 arraysize(binaries_to_evict), binaries_to_evict, | 1097 arraysize(binaries_to_evict), binaries_to_evict, |
995 false /* not important */, false); | 1098 false /* not important */, false); |
996 } | 1099 } |
997 | 1100 |
| 1101 TEST_F(ChromeFrameBinariesLoadTest, PerfColdPartialPreRead15) { |
| 1102 FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_}; |
| 1103 pre_read_type_ = kPreReadPartial; |
| 1104 percentage_to_preread_ = 15; |
| 1105 RunStartupTest("binary_load_cold_partial_preread", "t", "", true /* cold */, |
| 1106 arraysize(binaries_to_evict), binaries_to_evict, |
| 1107 false /* not important */, false); |
| 1108 } |
| 1109 |
| 1110 |
| 1111 TEST_F(ChromeFrameBinariesLoadTest, PerfColdPartialPreRead25) { |
| 1112 FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_}; |
| 1113 pre_read_type_ = kPreReadPartial; |
| 1114 percentage_to_preread_ = 25; |
| 1115 RunStartupTest("binary_load_cold_partial_preread", "t", "", true /* cold */, |
| 1116 arraysize(binaries_to_evict), binaries_to_evict, |
| 1117 false /* not important */, false); |
| 1118 } |
| 1119 |
| 1120 TEST_F(ChromeFrameBinariesLoadTest, PerfColdPartialPreRead40) { |
| 1121 FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_}; |
| 1122 pre_read_type_ = kPreReadPartial; |
| 1123 percentage_to_preread_ = 40; |
| 1124 RunStartupTest("binary_load_cold_partial_preread", "t", "", true /* cold */, |
| 1125 arraysize(binaries_to_evict), binaries_to_evict, |
| 1126 false /* not important */, false); |
| 1127 } |
| 1128 |
998 TEST_F(ChromeFrameStartupTestActiveXReference, PerfWarm) { | 1129 TEST_F(ChromeFrameStartupTestActiveXReference, PerfWarm) { |
999 RunStartupTest("warm", "t_ref", "about:blank", false /* cold */, 0, NULL, | 1130 RunStartupTest("warm", "t_ref", "about:blank", false /* cold */, 0, NULL, |
1000 true /* important */, false); | 1131 true /* important */, false); |
1001 } | 1132 } |
1002 | 1133 |
1003 TEST_F(ChromeFrameStartupTestActiveX, PerfChromeFrameInitializationWarm) { | 1134 TEST_F(ChromeFrameStartupTestActiveX, PerfChromeFrameInitializationWarm) { |
1004 RunStartupTest("ChromeFrame_init_warm", "t", "", false /* cold */, 0, | 1135 RunStartupTest("ChromeFrame_init_warm", "t", "", false /* cold */, 0, |
1005 NULL, true /* important */, false); | 1136 NULL, true /* important */, false); |
1006 } | 1137 } |
1007 | 1138 |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 PrintPerfTestResults(automation_provider_connect_monitor, kNumCycles, | 1599 PrintPerfTestResults(automation_provider_connect_monitor, kNumCycles, |
1469 "automationproviderconnect"); | 1600 "automationproviderconnect"); |
1470 PrintPerfTestResults(external_tab_navigate_monitor, kNumCycles, | 1601 PrintPerfTestResults(external_tab_navigate_monitor, kNumCycles, |
1471 "externaltabnavigate"); | 1602 "externaltabnavigate"); |
1472 PrintPerfTestResults(renderer_main_monitor, kNumCycles, | 1603 PrintPerfTestResults(renderer_main_monitor, kNumCycles, |
1473 "beginrenderermain"); | 1604 "beginrenderermain"); |
1474 #ifdef NDEBUG | 1605 #ifdef NDEBUG |
1475 PrintPerfTestResults(pre_read_chrome_monitor, kNumCycles, "PreReadImage"); | 1606 PrintPerfTestResults(pre_read_chrome_monitor, kNumCycles, "PreReadImage"); |
1476 #endif // NDEBUG | 1607 #endif // NDEBUG |
1477 } | 1608 } |
OLD | NEW |