| Index: chrome_frame/test/perf/chrome_frame_perftest.cc
|
| diff --git a/chrome_frame/test/perf/chrome_frame_perftest.cc b/chrome_frame/test/perf/chrome_frame_perftest.cc
|
| index 06de3432a2eaf531a929568adb0de60bceee8a4b..c96169a20da514a72534596d09a3ea3b11eaeada 100644
|
| --- a/chrome_frame/test/perf/chrome_frame_perftest.cc
|
| +++ b/chrome_frame/test/perf/chrome_frame_perftest.cc
|
| @@ -26,6 +26,7 @@
|
| #include "base/win/scoped_bstr.h"
|
| #include "base/win/scoped_comptr.h"
|
| #include "base/win/scoped_variant.h"
|
| +#include "chrome/app/image_pre_reader_win.h"
|
| #include "chrome/common/chrome_constants.h"
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_paths_internal.h"
|
| @@ -408,23 +409,39 @@ class ChromeFrameStartupTestActiveX : public ChromeFrameStartupTest {
|
| class ChromeFrameBinariesLoadTest : public ChromeFrameStartupTestActiveX {
|
| static const size_t kStepSize = 4 * 1024;
|
| public:
|
| + enum PreReadType {
|
| + kPreReadNone,
|
| + kPreReadPartial,
|
| + kPreReadFull
|
| + };
|
| +
|
| ChromeFrameBinariesLoadTest()
|
| - : pre_read_(false),
|
| + : pre_read_type_(kPreReadNone),
|
| step_size_(kStepSize),
|
| - bytes_to_read_(0) {}
|
| + bytes_to_read_(0),
|
| + percentage_to_preread_(25) {}
|
|
|
| protected:
|
| virtual void RunStartupTestImpl(TimeTicks* start_time,
|
| TimeTicks* end_time) {
|
| *start_time = TimeTicks::Now();
|
|
|
| - if (pre_read_) {
|
| - EXPECT_TRUE(file_util::PreReadImage(chrome_exe_.value().c_str(),
|
| - bytes_to_read_,
|
| - step_size_));
|
| - EXPECT_TRUE(file_util::PreReadImage(chrome_dll_.value().c_str(),
|
| - bytes_to_read_,
|
| - step_size_));
|
| + if (pre_read_type_ == kPreReadFull) {
|
| + EXPECT_TRUE(ImagePreReader::PreReadImage(chrome_exe_.value().c_str(),
|
| + bytes_to_read_,
|
| + step_size_));
|
| + EXPECT_TRUE(ImagePreReader::PreReadImage(chrome_dll_.value().c_str(),
|
| + bytes_to_read_,
|
| + step_size_));
|
| + } else if (pre_read_type_ == kPreReadPartial) {
|
| + EXPECT_TRUE(
|
| + ImagePreReader::PartialPreReadImage(chrome_exe_.value().c_str(),
|
| + percentage_to_preread_,
|
| + step_size_));
|
| + EXPECT_TRUE(
|
| + ImagePreReader::PartialPreReadImage(chrome_dll_.value().c_str(),
|
| + percentage_to_preread_,
|
| + step_size_));
|
| }
|
|
|
| HMODULE chrome_exe = LoadLibrary(chrome_exe_.value().c_str());
|
| @@ -439,9 +456,10 @@ class ChromeFrameBinariesLoadTest : public ChromeFrameStartupTestActiveX {
|
| FreeLibrary(chrome_dll);
|
| }
|
|
|
| - bool pre_read_;
|
| + PreReadType pre_read_type_;
|
| size_t bytes_to_read_;
|
| size_t step_size_;
|
| + uint8 percentage_to_preread_;
|
| };
|
|
|
| // This class provides functionality to run the startup performance test for
|
| @@ -926,6 +944,91 @@ class SilverlightCreationTest : public ChromeFrameStartupTest {
|
| }
|
| };
|
|
|
| +// TODO(rogerm): Flesh out the *PreReadImage* tests to validate an observed
|
| +// change in paging behaviour between raw loading and pre-reading.
|
| +
|
| +// TODO(rogerm): Add checks to the *PreReadImage* tests to validate the
|
| +// handling of invalid pe files and paths as input.
|
| +
|
| +TEST(ImagePreReader, PreReadImage) {
|
| + FilePath current_exe;
|
| + ASSERT_TRUE(PathService::Get(base::FILE_EXE, ¤t_exe));
|
| +
|
| + int64 file_size_64 = 0;
|
| + ASSERT_TRUE(file_util::GetFileSize(current_exe, &file_size_64));
|
| + ASSERT_TRUE(file_size_64 < std::numeric_limits<std::size_t>::max());
|
| + size_t file_size = static_cast<size_t>(file_size_64);
|
| +
|
| + const wchar_t* module_path = current_exe.value().c_str();
|
| + const size_t kStepSize = 2 * 1024 * 1024;
|
| +
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PreReadImage(module_path, 0, kStepSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PreReadImage(module_path, file_size / 4, kStepSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PreReadImage(module_path, file_size / 2, kStepSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PreReadImage(module_path, file_size, kStepSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PreReadImage(module_path, file_size * 2, kStepSize));
|
| +}
|
| +
|
| +TEST(ImagePreReader, PartialPreReadImage) {
|
| + FilePath current_exe;
|
| + ASSERT_TRUE(PathService::Get(base::FILE_EXE, ¤t_exe));
|
| +
|
| + const wchar_t* module_path = current_exe.value().c_str();
|
| + const size_t kStepSize = 2 * 1024 * 1024;
|
| +
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImage(module_path, 0, kStepSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImage(module_path, 25, kStepSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImage(module_path, 50, kStepSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImage(module_path, 100, kStepSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImage(module_path, 150, kStepSize));
|
| +}
|
| +
|
| +TEST(ImagePreReader, PartialPreReadImageOnDisk) {
|
| + FilePath current_exe;
|
| + ASSERT_TRUE(PathService::Get(base::FILE_EXE, ¤t_exe));
|
| +
|
| + const wchar_t* module_path = current_exe.value().c_str();
|
| + const size_t kChunkSize = 2 * 1024 * 1024;
|
| +
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImageOnDisk(module_path, 0, kChunkSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImageOnDisk(module_path, 25, kChunkSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImageOnDisk(module_path, 50, kChunkSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImageOnDisk(module_path, 100, kChunkSize));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImageOnDisk(module_path, 150, kChunkSize));
|
| +}
|
| +
|
| +TEST(ImagePreReader, PartialPreReadImageInMemory) {
|
| + FilePath current_exe;
|
| + ASSERT_TRUE(PathService::Get(base::FILE_EXE, ¤t_exe));
|
| + const wchar_t* module_path = current_exe.value().c_str();
|
| +
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImageInMemory(module_path, 0));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImageInMemory(module_path, 25));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImageInMemory(module_path, 50));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImageInMemory(module_path, 100));
|
| + ASSERT_TRUE(
|
| + ImagePreReader::PartialPreReadImageInMemory(module_path, 150));
|
| +}
|
| +
|
| TEST(ChromeFramePerf, DISABLED_HostActiveX) {
|
| // TODO(stoyan): Create a low integrity level thread && perform the test there
|
| SimpleModule module;
|
| @@ -989,12 +1092,40 @@ TEST_F(ChromeFrameBinariesLoadTest, PerfCold) {
|
|
|
| TEST_F(ChromeFrameBinariesLoadTest, PerfColdPreRead) {
|
| FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_};
|
| - pre_read_ = true;
|
| + pre_read_type_ = kPreReadFull;
|
| RunStartupTest("binary_load_cold_preread", "t", "", true /* cold */,
|
| arraysize(binaries_to_evict), binaries_to_evict,
|
| false /* not important */, false);
|
| }
|
|
|
| +TEST_F(ChromeFrameBinariesLoadTest, PerfColdPartialPreRead15) {
|
| + FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_};
|
| + pre_read_type_ = kPreReadPartial;
|
| + percentage_to_preread_ = 15;
|
| + RunStartupTest("binary_load_cold_partial_preread", "t", "", true /* cold */,
|
| + arraysize(binaries_to_evict), binaries_to_evict,
|
| + false /* not important */, false);
|
| +}
|
| +
|
| +
|
| +TEST_F(ChromeFrameBinariesLoadTest, PerfColdPartialPreRead25) {
|
| + FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_};
|
| + pre_read_type_ = kPreReadPartial;
|
| + percentage_to_preread_ = 25;
|
| + RunStartupTest("binary_load_cold_partial_preread", "t", "", true /* cold */,
|
| + arraysize(binaries_to_evict), binaries_to_evict,
|
| + false /* not important */, false);
|
| +}
|
| +
|
| +TEST_F(ChromeFrameBinariesLoadTest, PerfColdPartialPreRead40) {
|
| + FilePath binaries_to_evict[] = {chrome_exe_, chrome_dll_};
|
| + pre_read_type_ = kPreReadPartial;
|
| + percentage_to_preread_ = 40;
|
| + RunStartupTest("binary_load_cold_partial_preread", "t", "", true /* cold */,
|
| + arraysize(binaries_to_evict), binaries_to_evict,
|
| + false /* not important */, false);
|
| +}
|
| +
|
| TEST_F(ChromeFrameStartupTestActiveXReference, PerfWarm) {
|
| RunStartupTest("warm", "t_ref", "about:blank", false /* cold */, 0, NULL,
|
| true /* important */, false);
|
|
|