blob: aeed60c6513d323605be5b97f66bd157c6139e03 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// Copyright 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 MeasureTimeToLoadNativeLibrary(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);
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;
base::UnloadNativeLibrary(native_library);
perf_test::PrintResult("time_to_load_library",
"",
library_name.AsUTF8Unsafe(),
delta,
"ms",
true);
}
// Use the base name of the library to dynamically get the platform specific
// name. See base::GetNativeLibraryName() for details.
void MeasureTimeToLoadNativeLibraryByBaseName(
const std::string& base_library_name) {
MeasureTimeToLoadNativeLibrary(base::FilePath::FromUTF16Unsafe(
base::GetNativeLibraryName(base::ASCIIToUTF16(base_library_name))));
}
#if defined(ENABLE_PEPPER_CDMS)
#if defined(WIDEVINE_CDM_AVAILABLE)
TEST(LoadCDMPerfTest, Widevine) {
MeasureTimeToLoadNativeLibrary(
base::FilePath::FromUTF8Unsafe(kWidevineCdmFileName));
}
TEST(LoadCDMPerfTest, WidevineAdapter) {
MeasureTimeToLoadNativeLibrary(
base::FilePath::FromUTF8Unsafe(kWidevineCdmAdapterFileName));
}
#endif // defined(WIDEVINE_CDM_AVAILABLE)
TEST(LoadCDMPerfTest, ExternalClearKey) {
MeasureTimeToLoadNativeLibraryByBaseName("clearkeycdm");
}
TEST(LoadCDMPerfTest, ExternalClearKeyAdapter) {
MeasureTimeToLoadNativeLibraryByBaseName("clearkeycdmadapter");
}
#endif // defined(ENABLE_PEPPER_CDMS)
|