| 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> |
| 11 | 11 |
| 12 #include "chrome_tab.h" // Generated from chrome_tab.idl. | 12 #include "chrome_tab.h" // Generated from chrome_tab.idl. |
| 13 | 13 |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/file_util.h" |
| 15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 16 #include "base/process_util.h" | 17 #include "base/process_util.h" |
| 17 #include "base/registry.h" | 18 #include "base/registry.h" |
| 18 #include "base/scoped_ptr.h" | 19 #include "base/scoped_ptr.h" |
| 19 #include "base/scoped_bstr_win.h" | 20 #include "base/scoped_bstr_win.h" |
| 20 #include "base/scoped_comptr_win.h" | 21 #include "base/scoped_comptr_win.h" |
| 21 #include "base/scoped_variant_win.h" | 22 #include "base/scoped_variant_win.h" |
| 22 #include "base/string_util.h" | 23 #include "base/string_util.h" |
| 23 #include "base/time.h" | 24 #include "base/time.h" |
| 24 #include "chrome/common/chrome_constants.h" | 25 #include "chrome/common/chrome_constants.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 CComObjectStackEx<ChromeFrameActiveXContainer> wnd; | 398 CComObjectStackEx<ChromeFrameActiveXContainer> wnd; |
| 398 wnd.CreateChromeFrameWindow(startup_url_); | 399 wnd.CreateChromeFrameWindow(startup_url_); |
| 399 wnd.CreateControl(true); | 400 wnd.CreateControl(true); |
| 400 module.RunMessageLoop(); | 401 module.RunMessageLoop(); |
| 401 *end_time = TimeTicks::Now(); | 402 *end_time = TimeTicks::Now(); |
| 402 } | 403 } |
| 403 }; | 404 }; |
| 404 | 405 |
| 405 // This class measures the load time of chrome and chrome frame binaries | 406 // This class measures the load time of chrome and chrome frame binaries |
| 406 class ChromeFrameBinariesLoadTest : public ChromeFrameStartupTestActiveX { | 407 class ChromeFrameBinariesLoadTest : public ChromeFrameStartupTestActiveX { |
| 408 static const size_t kStepSize = 4 * 1024; |
| 409 public: |
| 410 ChromeFrameBinariesLoadTest() |
| 411 : pre_read_(false), |
| 412 step_size_(kStepSize), |
| 413 bytes_to_read_(0) {} |
| 414 |
| 407 protected: | 415 protected: |
| 408 virtual void RunStartupTestImpl(TimeTicks* start_time, | 416 virtual void RunStartupTestImpl(TimeTicks* start_time, |
| 409 TimeTicks* end_time) { | 417 TimeTicks* end_time) { |
| 410 *start_time = TimeTicks::Now(); | 418 *start_time = TimeTicks::Now(); |
| 411 | 419 |
| 420 if (pre_read_) { |
| 421 EXPECT_TRUE(file_util::PreReadImage(chrome_exe_.value().c_str(), |
| 422 bytes_to_read_, |
| 423 step_size_)); |
| 424 EXPECT_TRUE(file_util::PreReadImage(chrome_dll_.value().c_str(), |
| 425 bytes_to_read_, |
| 426 step_size_)); |
| 427 } |
| 428 |
| 412 HMODULE chrome_exe = LoadLibrary(chrome_exe_.value().c_str()); | 429 HMODULE chrome_exe = LoadLibrary(chrome_exe_.value().c_str()); |
| 413 ASSERT_TRUE(chrome_exe != NULL); | 430 EXPECT_TRUE(chrome_exe != NULL); |
| 414 | 431 |
| 415 HMODULE chrome_dll = LoadLibrary(chrome_dll_.value().c_str()); | 432 HMODULE chrome_dll = LoadLibrary(chrome_dll_.value().c_str()); |
| 416 ASSERT_TRUE(chrome_dll != NULL); | 433 EXPECT_TRUE(chrome_dll != NULL); |
| 417 | |
| 418 HMODULE chrome_tab_dll = LoadLibrary(chrome_frame_dll_.value().c_str()); | |
| 419 ASSERT_TRUE(chrome_tab_dll != NULL); | |
| 420 | 434 |
| 421 *end_time = TimeTicks::Now(); | 435 *end_time = TimeTicks::Now(); |
| 422 | 436 |
| 423 FreeLibrary(chrome_exe); | 437 FreeLibrary(chrome_exe); |
| 424 FreeLibrary(chrome_dll); | 438 FreeLibrary(chrome_dll); |
| 425 FreeLibrary(chrome_tab_dll); | |
| 426 } | 439 } |
| 440 |
| 441 bool pre_read_; |
| 442 size_t bytes_to_read_; |
| 443 size_t step_size_; |
| 427 }; | 444 }; |
| 428 | 445 |
| 429 // This class provides functionality to run the startup performance test for | 446 // This class provides functionality to run the startup performance test for |
| 430 // the ChromeFrame ActiveX against a reference build. At this point we only run | 447 // the ChromeFrame ActiveX against a reference build. At this point we only run |
| 431 // this test in warm mode. | 448 // this test in warm mode. |
| 432 class ChromeFrameStartupTestActiveXReference | 449 class ChromeFrameStartupTestActiveXReference |
| 433 : public ChromeFrameStartupTestActiveX { | 450 : public ChromeFrameStartupTestActiveX { |
| 434 public: | 451 public: |
| 435 // override the browser directory to use the reference build instead. | 452 // override the browser directory to use the reference build instead. |
| 436 virtual void SetUp() { | 453 virtual void SetUp() { |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 RunStartupTest("warm", "t", "about:blank", false /* cold */, 0, NULL, | 939 RunStartupTest("warm", "t", "about:blank", false /* cold */, 0, NULL, |
| 923 true /* important */, false); | 940 true /* important */, false); |
| 924 } | 941 } |
| 925 | 942 |
| 926 TEST_F(ChromeFrameBinariesLoadTest, PerfWarm) { | 943 TEST_F(ChromeFrameBinariesLoadTest, PerfWarm) { |
| 927 RunStartupTest("binary_load_warm", "t", "", false /* cold */, 0, NULL, | 944 RunStartupTest("binary_load_warm", "t", "", false /* cold */, 0, NULL, |
| 928 true /* important */, false); | 945 true /* important */, false); |
| 929 } | 946 } |
| 930 | 947 |
| 931 TEST_F(ChromeFrameStartupTestActiveX, PerfCold) { | 948 TEST_F(ChromeFrameStartupTestActiveX, PerfCold) { |
| 949 SetConfigInt(L"PreRead", 0); |
| 932 FilePath binaries_to_evict[] = { gears_dll_, avcodec52_dll_, | 950 FilePath binaries_to_evict[] = { gears_dll_, avcodec52_dll_, |
| 933 avformat52_dll_, avutil50_dll_, chrome_exe_, chrome_dll_, | 951 avformat52_dll_, avutil50_dll_, chrome_exe_, chrome_dll_, |
| 934 chrome_frame_dll_}; | 952 chrome_frame_dll_}; |
| 935 RunStartupTest("cold", "t", "about:blank", true /* cold */, | 953 RunStartupTest("cold", "t", "about:blank", true /* cold */, |
| 936 arraysize(binaries_to_evict), binaries_to_evict, | 954 arraysize(binaries_to_evict), binaries_to_evict, |
| 937 false /* not important */, false); | 955 false /* not important */, false); |
| 956 DeleteConfigValue(L"PreRead"); |
| 957 } |
| 958 |
| 959 TEST_F(ChromeFrameStartupTestActiveX, PerfColdPreRead) { |
| 960 SetConfigInt(L"PreRead", 1); |
| 961 FilePath binaries_to_evict[] = { gears_dll_, avcodec52_dll_, |
| 962 avformat52_dll_, avutil50_dll_, chrome_exe_, chrome_dll_, |
| 963 chrome_frame_dll_}; |
| 964 RunStartupTest("cold_preread", "t", "about:blank", true /* cold */, |
| 965 arraysize(binaries_to_evict), binaries_to_evict, |
| 966 false /* not important */, false); |
| 967 DeleteConfigValue(L"PreRead"); |
| 938 } | 968 } |
| 939 | 969 |
| 940 TEST_F(ChromeFrameBinariesLoadTest, PerfCold) { | 970 TEST_F(ChromeFrameBinariesLoadTest, PerfCold) { |
| 941 FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_, chrome_frame_dll_}; | 971 FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_}; |
| 942 RunStartupTest("binary_load_cold", "t", "", true /* cold */, | 972 RunStartupTest("binary_load_cold", "t", "", true /* cold */, |
| 943 arraysize(binaries_to_evict), binaries_to_evict, | 973 arraysize(binaries_to_evict), binaries_to_evict, |
| 944 false /* not important */, false); | 974 false /* not important */, false); |
| 945 } | 975 } |
| 946 | 976 |
| 977 TEST_F(ChromeFrameBinariesLoadTest, PerfColdPreRead) { |
| 978 FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_}; |
| 979 pre_read_ = true; |
| 980 RunStartupTest("binary_load_cold_preread", "t", "", true /* cold */, |
| 981 arraysize(binaries_to_evict), binaries_to_evict, |
| 982 false /* not important */, false); |
| 983 } |
| 984 |
| 947 TEST_F(ChromeFrameStartupTestActiveXReference, PerfWarm) { | 985 TEST_F(ChromeFrameStartupTestActiveXReference, PerfWarm) { |
| 948 RunStartupTest("warm", "t_ref", "about:blank", false /* cold */, 0, NULL, | 986 RunStartupTest("warm", "t_ref", "about:blank", false /* cold */, 0, NULL, |
| 949 true /* important */, false); | 987 true /* important */, false); |
| 950 } | 988 } |
| 951 | 989 |
| 952 TEST_F(ChromeFrameStartupTestActiveX, PerfChromeFrameInitializationWarm) { | 990 TEST_F(ChromeFrameStartupTestActiveX, PerfChromeFrameInitializationWarm) { |
| 953 RunStartupTest("ChromeFrame_init_warm", "t", "", false /* cold */, 0, | 991 RunStartupTest("ChromeFrame_init_warm", "t", "", false /* cold */, 0, |
| 954 NULL, true /* important */, false); | 992 NULL, true /* important */, false); |
| 955 } | 993 } |
| 956 | 994 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 ASSERT_TRUE(silverlight_key.ReadValue(L"", &plugin_path)); | 1113 ASSERT_TRUE(silverlight_key.ReadValue(L"", &plugin_path)); |
| 1076 ASSERT_FALSE(plugin_path.empty()); | 1114 ASSERT_FALSE(plugin_path.empty()); |
| 1077 | 1115 |
| 1078 FilePath silverlight_path = FilePath::FromWStringHack(plugin_path); | 1116 FilePath silverlight_path = FilePath::FromWStringHack(plugin_path); |
| 1079 FilePath binaries_to_evict[] = {silverlight_path}; | 1117 FilePath binaries_to_evict[] = {silverlight_path}; |
| 1080 | 1118 |
| 1081 RunStartupTest("creation_cold", "t_silverlight", "", true /* cold */, | 1119 RunStartupTest("creation_cold", "t_silverlight", "", true /* cold */, |
| 1082 arraysize(binaries_to_evict), binaries_to_evict, | 1120 arraysize(binaries_to_evict), binaries_to_evict, |
| 1083 false /* important */, true); | 1121 false /* important */, true); |
| 1084 } | 1122 } |
| OLD | NEW |