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

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

Issue 184733004: Perf tests that measure time to load libraries (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix Windows compile issue. Created 6 years, 9 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
OLDNEW
(Empty)
1 // Copyright 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 ASSERT_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 ASSERT_TRUE(native_library) << "Error loading library:\n" << error;
25 base::UnloadNativeLibrary(native_library);
26 perf_test::PrintResult("time_to_load_library",
27 "",
28 library_name.AsUTF8Unsafe(),
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::FromUTF8Unsafe(kWidevineCdmFileName));
47 }
48
49 TEST(LoadCDMPerfTest, WidevineAdapter) {
50 MeasureTimeToLoadNativeLibrary(
51 base::FilePath::FromUTF8Unsafe(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 | « build/all.gyp ('k') | chrome/chrome_tests.gypi » ('j') | chrome/chrome_tests.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698