| OLD | NEW |
| 1 // Copyright (c) 2009 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 #ifndef BASE_TEST_PERF_TEST_SUITE_H_ | 5 #ifndef BASE_TEST_PERF_TEST_SUITE_H_ |
| 6 #define BASE_TEST_PERF_TEST_SUITE_H_ | 6 #define BASE_TEST_PERF_TEST_SUITE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/debug_util.h" | |
| 11 #include "base/file_path.h" | |
| 12 #include "base/perftimer.h" | |
| 13 #include "base/process_util.h" | |
| 14 #include "base/string_util.h" | |
| 15 #include "base/test/test_suite.h" | 10 #include "base/test/test_suite.h" |
| 16 | 11 |
| 12 namespace base { |
| 13 |
| 17 class PerfTestSuite : public TestSuite { | 14 class PerfTestSuite : public TestSuite { |
| 18 public: | 15 public: |
| 19 PerfTestSuite(int argc, char** argv) : TestSuite(argc, argv) { | 16 PerfTestSuite(int argc, char** argv); |
| 20 } | |
| 21 | 17 |
| 22 virtual void Initialize() { | 18 virtual void Initialize(); |
| 23 TestSuite::Initialize(); | 19 virtual void Shutdown(); |
| 24 | 20 |
| 25 // Initialize the perf timer log | 21 private: |
| 26 FilePath log_path = | 22 DISALLOW_COPY_AND_ASSIGN(PerfTestSuite); |
| 27 CommandLine::ForCurrentProcess()->GetSwitchValuePath("log-file"); | |
| 28 if (log_path.empty()) { | |
| 29 FilePath exe; | |
| 30 PathService::Get(base::FILE_EXE, &exe); | |
| 31 log_path = exe.ReplaceExtension(FILE_PATH_LITERAL("log")); | |
| 32 log_path = log_path.InsertBeforeExtension(FILE_PATH_LITERAL("_perf")); | |
| 33 } | |
| 34 ASSERT_TRUE(InitPerfLog(log_path)); | |
| 35 | |
| 36 // Raise to high priority to have more precise measurements. Since we don't | |
| 37 // aim at 1% precision, it is not necessary to run at realtime level. | |
| 38 if (!DebugUtil::BeingDebugged()) | |
| 39 base::RaiseProcessToHighPriority(); | |
| 40 } | |
| 41 | |
| 42 virtual void Shutdown() { | |
| 43 TestSuite::Shutdown(); | |
| 44 | |
| 45 FinalizePerfLog(); | |
| 46 } | |
| 47 }; | 23 }; |
| 48 | 24 |
| 25 } // namespace base |
| 26 |
| 49 #endif // BASE_TEST_PERF_TEST_SUITE_H_ | 27 #endif // BASE_TEST_PERF_TEST_SUITE_H_ |
| OLD | NEW |