| 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" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/debugger.h" | 8 #include "base/debug/debugger.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/process/launch.h" | 11 #include "base/process/launch.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/test/perf_log.h" | 13 #include "base/test/perf_log.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 | 17 |
| 18 PerfTestSuite::PerfTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} | 18 PerfTestSuite::PerfTestSuite(int argc, char** argv) : TestSuite(argc, argv) {} |
| 19 | 19 |
| 20 void PerfTestSuite::Initialize() { | 20 void PerfTestSuite::Initialize() { |
| 21 TestSuite::Initialize(); | 21 TestSuite::Initialize(); |
| 22 | 22 |
| 23 // Initialize the perf timer log | 23 // Initialize the perf timer log |
| 24 FilePath log_path = | 24 FilePath log_path = |
| 25 CommandLine::ForCurrentProcess()->GetSwitchValuePath("log-file"); | 25 CommandLine::ForCurrentProcess()->GetSwitchValuePath("log-file"); |
| 26 if (log_path.empty()) { | 26 if (log_path.empty()) { |
| 27 FilePath exe; | 27 PathService::Get(FILE_EXE, &log_path); |
| 28 PathService::Get(FILE_EXE, &exe); | 28 #if defined(OS_ANDROID) |
| 29 log_path = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); | 29 base::FilePath tmp_dir; |
| 30 PathService::Get(base::DIR_CACHE, &tmp_dir); |
| 31 log_path = tmp_dir.Append(log_path.BaseName()); |
| 32 #endif |
| 33 log_path = log_path.ReplaceExtension(FILE_PATH_LITERAL("log")); |
| 30 log_path = log_path.InsertBeforeExtension(FILE_PATH_LITERAL("_perf")); | 34 log_path = log_path.InsertBeforeExtension(FILE_PATH_LITERAL("_perf")); |
| 31 } | 35 } |
| 32 ASSERT_TRUE(InitPerfLog(log_path)); | 36 ASSERT_TRUE(InitPerfLog(log_path)); |
| 33 | 37 |
| 34 // Raise to high priority to have more precise measurements. Since we don't | 38 // Raise to high priority to have more precise measurements. Since we don't |
| 35 // aim at 1% precision, it is not necessary to run at realtime level. | 39 // aim at 1% precision, it is not necessary to run at realtime level. |
| 36 if (!debug::BeingDebugged()) | 40 if (!debug::BeingDebugged()) |
| 37 RaiseProcessToHighPriority(); | 41 RaiseProcessToHighPriority(); |
| 38 } | 42 } |
| 39 | 43 |
| 40 void PerfTestSuite::Shutdown() { | 44 void PerfTestSuite::Shutdown() { |
| 41 TestSuite::Shutdown(); | 45 TestSuite::Shutdown(); |
| 42 FinalizePerfLog(); | 46 FinalizePerfLog(); |
| 43 } | 47 } |
| 44 | 48 |
| 45 } // namespace base | 49 } // namespace base |
| OLD | NEW |