OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/test/perf_test_suite.h" | 5 #include "base/test/perf_test_suite.h" |
6 | 6 |
7 #include "base/command_line.h" | |
8 #include "base/debug/debugger.h" | 7 #include "base/debug/debugger.h" |
9 #include "base/files/file_path.h" | |
10 #include "base/path_service.h" | |
11 #include "base/process/launch.h" | 8 #include "base/process/launch.h" |
12 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
13 #include "base/test/perf_log.h" | 10 #include "base/test/perf_log.h" |
14 #include "build/build_config.h" | |
15 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
16 | 12 |
17 namespace base { | 13 namespace base { |
18 | 14 |
19 PerfTestSuite::PerfTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} | 15 PerfTestSuite::PerfTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} |
20 | 16 |
21 void PerfTestSuite::Initialize() { | 17 void PerfTestSuite::Initialize() { |
22 TestSuite::Initialize(); | 18 TestSuite::Initialize(); |
23 | 19 |
24 // Initialize the perf timer log | 20 // Initialize the perf timer log |
25 FilePath log_path = | 21 ASSERT_TRUE(InitPerfLog()); |
26 CommandLine::ForCurrentProcess()->GetSwitchValuePath("log-file"); | |
27 if (log_path.empty()) { | |
28 PathService::Get(FILE_EXE, &log_path); | |
29 #if defined(OS_ANDROID) | |
30 base::FilePath tmp_dir; | |
31 PathService::Get(base::DIR_CACHE, &tmp_dir); | |
32 log_path = tmp_dir.Append(log_path.BaseName()); | |
33 #endif | |
34 log_path = log_path.ReplaceExtension(FILE_PATH_LITERAL("log")); | |
35 log_path = log_path.InsertBeforeExtension(FILE_PATH_LITERAL("_perf")); | |
36 } | |
37 ASSERT_TRUE(InitPerfLog(log_path)); | |
38 | 22 |
39 // Raise to high priority to have more precise measurements. Since we don't | 23 // Raise to high priority to have more precise measurements. Since we don't |
40 // aim at 1% precision, it is not necessary to run at realtime level. | 24 // aim at 1% precision, it is not necessary to run at realtime level. |
41 if (!debug::BeingDebugged()) | 25 if (!debug::BeingDebugged()) |
42 RaiseProcessToHighPriority(); | 26 RaiseProcessToHighPriority(); |
43 } | 27 } |
44 | 28 |
45 void PerfTestSuite::Shutdown() { | 29 void PerfTestSuite::Shutdown() { |
46 TestSuite::Shutdown(); | 30 TestSuite::Shutdown(); |
47 FinalizePerfLog(); | 31 FinalizePerfLog(); |
48 } | 32 } |
49 | 33 |
50 } // namespace base | 34 } // namespace base |
OLD | NEW |