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