Index: chrome/browser/load_library_perf_test.cc |
diff --git a/chrome/browser/load_library_perf_test.cc b/chrome/browser/load_library_perf_test.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1c12afa684a3f5e90af9270c336deaf9a5e508c1 |
--- /dev/null |
+++ b/chrome/browser/load_library_perf_test.cc |
@@ -0,0 +1,54 @@ |
+// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/files/file_path.h" |
+#include "base/path_service.h" |
+#include "base/scoped_native_library.h" |
+#include "base/strings/utf_string_conversions.h" |
+#include "base/time/time.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+#include "testing/perf/perf_test.h" |
+#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
+ |
+ |
+void MeasureTimeToLoad(const std::string& library_name) { |
+ base::NativeLibrary native_library; |
+ base::FilePath library_full_name; |
+ library_full_name = base::FilePath::FromUTF16Unsafe( |
xhwang
2014/02/08 05:29:38
Can you merge line 17 and 18?
shadi1
2014/02/10 20:22:28
Done.
|
+ base::GetNativeLibraryName(base::ASCIIToUTF16(library_name))); |
+ base::FilePath output_dir; |
+ EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &output_dir)); |
+ base::FilePath library_path = output_dir.Append(library_full_name); |
+ std::string error; |
+ base::TimeTicks start = base::TimeTicks::HighResNow(); |
+ native_library = base::LoadNativeLibrary(library_path, &error); |
xhwang
2014/02/08 05:29:38
Merge line 16 into this line?
shadi1
2014/02/10 20:22:28
Done.
|
+ double delta = (base::TimeTicks::HighResNow() - start).InMillisecondsF(); |
+ EXPECT_TRUE(native_library) << "Error loading library:\n" << error; |
+ perf_test::PrintResult("time_to_load_library", |
+ "", |
+ library_full_name.value(), |
+ delta, |
+ "ms", |
+ true); |
+} |
+ |
+#if defined(ENABLE_PEPPER_CDMS) |
+#if defined(WIDEVINE_CDM_AVAILABLE) |
+TEST(LoadCDMPerfTest, Widevine) { |
+ MeasureTimeToLoad("widevinecdm"); |
xhwang
2014/02/08 05:29:38
How about using kWidevineCdmFileName in widevine_c
shadi1
2014/02/10 20:22:28
The reason is because kWidevineCdmFileName already
|
+} |
+ |
+TEST(LoadCDMPerfTest, WidevineAdapter) { |
+ MeasureTimeToLoad("widevinecdmadapter"); |
xhwang
2014/02/08 05:29:38
Ditto about using kWidevineCdmAdapterFileName.
|
+} |
+#endif // defined(WIDEVINE_CDM_AVAILABLE) |
+ |
+TEST(LoadCDMPerfTest, ExternalClearKey) { |
+ MeasureTimeToLoad("clearkeycdm"); |
+} |
+ |
+TEST(LoadCDMPerfTest, ExternalClearKeyAdapter) { |
+ MeasureTimeToLoad("clearkeycdmadapter"); |
+} |
+#endif // defined(ENABLE_PEPPER_CDMS) |