Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: chrome/browser/load_library_perf_test.cc

Issue 151283003: Perf test to measure loading CDM library. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: nits, master rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | chrome/chrome_tests.gypi » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
Lei Zhang 2014/02/12 20:25:06 nit: no (c)
shadi1 2014/02/12 20:49:24 Done.
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));
Lei Zhang 2014/02/12 20:25:06 I'd ASSERT_TRUE() here so you don't accidentally l
shadi1 2014/02/12 20:49:24 Done.
18 base::FilePath library_path = output_dir.Append(library_name);
Lei Zhang 2014/02/12 20:25:06 Just use AppendASCII() so MeasureTimeToLoadNativeL
shadi1 2014/02/12 20:49:24 I wanted |library_name| to be a FilePath in case t
Lei Zhang 2014/02/12 21:03:56 Ok, that's fine. I thought it's just a simple name
19 std::string error;
20 base::TimeTicks start = base::TimeTicks::HighResNow();
21 base::NativeLibrary native_library =
Lei Zhang 2014/02/12 20:25:06 check this isn't null
shadi1 2014/02/12 20:49:24 This was done in l.25 EXPECT_TRUE(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. See base::GetNativeLibraryName() for details.
36 void MeasureTimeToLoadNativeLibraryByBaseName(
37 const std::string& base_library_name) {
38 MeasureTimeToLoadNativeLibrary(base::FilePath::FromUTF16Unsafe(
39 base::GetNativeLibraryName(base::ASCIIToUTF16(base_library_name))));
40 }
41
42 #if defined(ENABLE_PEPPER_CDMS)
43 #if defined(WIDEVINE_CDM_AVAILABLE)
44 TEST(LoadCDMPerfTest, Widevine) {
45 MeasureTimeToLoadNativeLibrary(
46 base::FilePath(FILE_PATH_LITERAL(kWidevineCdmFileName)));
47 }
48
49 TEST(LoadCDMPerfTest, WidevineAdapter) {
50 MeasureTimeToLoadNativeLibrary(
51 base::FilePath(FILE_PATH_LITERAL(kWidevineCdmAdapterFileName)));
52 }
53 #endif // defined(WIDEVINE_CDM_AVAILABLE)
54
55 TEST(LoadCDMPerfTest, ExternalClearKey) {
56 MeasureTimeToLoadNativeLibraryByBaseName("clearkeycdm");
57 }
58
59 TEST(LoadCDMPerfTest, ExternalClearKeyAdapter) {
60 MeasureTimeToLoadNativeLibraryByBaseName("clearkeycdmadapter");
61 }
62 #endif // defined(ENABLE_PEPPER_CDMS)
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | chrome/chrome_tests.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698