From 07e54d4006e32f151375768e4882ebfa7d59f867 Mon Sep 17 00:00:00 2001 From: "shadi@chromium.org" Date: Wed, 19 Mar 2014 06:15:09 +0000 Subject: [PATCH] Measure size of library in load_library_perf_tests (in bytes.) Fix mac only clearkeycdm library names. BUG=353215,352952 TBR=sky Review URL: https://codereview.chromium.org/202323002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257866 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/load_library_perf_test.cc | 40 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/chrome/browser/load_library_perf_test.cc b/chrome/browser/load_library_perf_test.cc index aeed60c6513d..c35cd0bb8694 100644 --- a/chrome/browser/load_library_perf_test.cc +++ b/chrome/browser/load_library_perf_test.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/file_util.h" #include "base/files/file_path.h" #include "base/path_service.h" #include "base/scoped_native_library.h" @@ -11,17 +12,28 @@ #include "testing/perf/perf_test.h" #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. - -void MeasureTimeToLoadNativeLibrary(const base::FilePath& library_name) { +// Measures the size (bytes) and time to load (sec) of a native library. +void MeasureSizeAndTimeToLoadNativeLibrary(const base::FilePath& library_name) { base::FilePath output_dir; ASSERT_TRUE(PathService::Get(base::DIR_MODULE, &output_dir)); base::FilePath library_path = output_dir.Append(library_name); + ASSERT_TRUE(base::PathExists(library_path)) << library_path.value(); + + int64 size = 0; + ASSERT_TRUE(base::GetFileSize(library_path, &size)); + perf_test::PrintResult("library_size", + "", + library_name.AsUTF8Unsafe(), + static_cast(size), + "bytes", + true); + std::string error; base::TimeTicks start = base::TimeTicks::HighResNow(); base::NativeLibrary native_library = base::LoadNativeLibrary(library_path, &error); double delta = (base::TimeTicks::HighResNow() - start).InMillisecondsF(); - ASSERT_TRUE(native_library) << "Error loading library:\n" << error; + ASSERT_TRUE(native_library) << "Error loading library: " << error; base::UnloadNativeLibrary(native_library); perf_test::PrintResult("time_to_load_library", "", @@ -33,30 +45,40 @@ void MeasureTimeToLoadNativeLibrary(const base::FilePath& library_name) { // Use the base name of the library to dynamically get the platform specific // name. See base::GetNativeLibraryName() for details. -void MeasureTimeToLoadNativeLibraryByBaseName( +void MeasureSizeAndTimeToLoadNativeLibraryByBaseName( const std::string& base_library_name) { - MeasureTimeToLoadNativeLibrary(base::FilePath::FromUTF16Unsafe( + MeasureSizeAndTimeToLoadNativeLibrary(base::FilePath::FromUTF16Unsafe( base::GetNativeLibraryName(base::ASCIIToUTF16(base_library_name)))); } #if defined(ENABLE_PEPPER_CDMS) #if defined(WIDEVINE_CDM_AVAILABLE) TEST(LoadCDMPerfTest, Widevine) { - MeasureTimeToLoadNativeLibrary( + MeasureSizeAndTimeToLoadNativeLibrary( base::FilePath::FromUTF8Unsafe(kWidevineCdmFileName)); } TEST(LoadCDMPerfTest, WidevineAdapter) { - MeasureTimeToLoadNativeLibrary( + MeasureSizeAndTimeToLoadNativeLibrary( base::FilePath::FromUTF8Unsafe(kWidevineCdmAdapterFileName)); } #endif // defined(WIDEVINE_CDM_AVAILABLE) TEST(LoadCDMPerfTest, ExternalClearKey) { - MeasureTimeToLoadNativeLibraryByBaseName("clearkeycdm"); +#if defined(OS_MACOSX) + MeasureSizeAndTimeToLoadNativeLibrary( + base::FilePath::FromUTF8Unsafe("libclearkeycdm.dylib")); +#else + MeasureSizeAndTimeToLoadNativeLibraryByBaseName("clearkeycdm"); +#endif // defined(OS_MACOSX) } TEST(LoadCDMPerfTest, ExternalClearKeyAdapter) { - MeasureTimeToLoadNativeLibraryByBaseName("clearkeycdmadapter"); +#if defined(OS_MACOSX) + MeasureSizeAndTimeToLoadNativeLibrary( + base::FilePath::FromUTF8Unsafe("clearkeycdmadapter.plugin")); +#else + MeasureSizeAndTimeToLoadNativeLibraryByBaseName("clearkeycdmadapter"); +#endif // defined(OS_MACOSX) } #endif // defined(ENABLE_PEPPER_CDMS) -- 2.11.4.GIT