OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/files/file_path.h" | |
6 #include "base/path_service.h" | |
7 #include "base/scoped_native_library.h" | |
8 #include "base/strings/utf_string_conversions.h" | |
9 #include "base/time/time.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 #include "testing/perf/perf_test.h" | |
12 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | |
13 | |
14 | |
15 void MeasureTimeToLoadNativeLibrary(const base::FilePath& library_name) { | |
16 base::FilePath output_dir; | |
17 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &output_dir)); | |
18 base::FilePath library_path = output_dir.Append(library_name); | |
19 std::string error; | |
20 base::TimeTicks start = base::TimeTicks::HighResNow(); | |
21 base::NativeLibrary native_library = | |
22 base::LoadNativeLibrary(library_path, &error); | |
23 double delta = (base::TimeTicks::HighResNow() - start).InMillisecondsF(); | |
24 base::UnloadNativeLibrary(native_library); | |
25 EXPECT_TRUE(native_library) << "Error loading library:\n" << error; | |
26 perf_test::PrintResult("time_to_load_library", | |
27 "", | |
28 library_name.value(), | |
29 delta, | |
30 "ms", | |
31 true); | |
32 } | |
33 | |
34 // Use the base name of the library to dynamically get the platform specific | |
35 // name. Check base::GetNativeLibraryName() for details. | |
ddorwin
2014/02/12 18:12:52
nit: s/Check/See/
shadi1
2014/02/12 18:34:06
Done.
| |
36 void MeasureTimeToLoadLibraryByBaseName(const std::string& base_library_name) { | |
ddorwin
2014/02/12 18:12:52
nit: MeasureTimeToLoad*Native*LibraryByBaseName
shadi1
2014/02/12 18:34:06
Done.
| |
37 MeasureTimeToLoadNativeLibrary(base::FilePath::FromUTF16Unsafe( | |
38 base::GetNativeLibraryName(base::ASCIIToUTF16(base_library_name)))); | |
39 } | |
40 | |
41 #if defined(ENABLE_PEPPER_CDMS) | |
42 #if defined(WIDEVINE_CDM_AVAILABLE) | |
43 TEST(LoadCDMPerfTest, Widevine) { | |
44 MeasureTimeToLoadNativeLibrary( | |
45 base::FilePath(FILE_PATH_LITERAL(kWidevineCdmFileName))); | |
46 } | |
47 | |
48 TEST(LoadCDMPerfTest, WidevineAdapter) { | |
49 MeasureTimeToLoadNativeLibrary( | |
50 base::FilePath(FILE_PATH_LITERAL(kWidevineCdmAdapterFileName))); | |
51 } | |
52 #endif // defined(WIDEVINE_CDM_AVAILABLE) | |
53 | |
54 TEST(LoadCDMPerfTest, ExternalClearKey) { | |
55 MeasureTimeToLoadLibraryByBaseName("clearkeycdm"); | |
56 } | |
57 | |
58 TEST(LoadCDMPerfTest, ExternalClearKeyAdapter) { | |
59 MeasureTimeToLoadLibraryByBaseName("clearkeycdmadapter"); | |
60 } | |
61 #endif // defined(ENABLE_PEPPER_CDMS) | |
OLD | NEW |