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

Side by Side Diff: base/test/perf_test_suite.cc

Issue 3026055: Cleanup in base. This moves the implementation (and a bunch of header file... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 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 | Annotate | Revision Log
OLDNEW
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 #include "base/test/perf_test_suite.h"
6 #define BASE_TEST_PERF_TEST_SUITE_H_
7 #pragma once
8 6
9 #include "base/command_line.h" 7 #include "base/command_line.h"
10 #include "base/debug_util.h" 8 #include "base/debug_util.h"
11 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/path_service.h"
12 #include "base/perftimer.h" 11 #include "base/perftimer.h"
13 #include "base/process_util.h" 12 #include "base/process_util.h"
14 #include "base/string_util.h"
15 #include "base/test/test_suite.h" 13 #include "base/test/test_suite.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 15
17 class PerfTestSuite : public TestSuite { 16 namespace base {
18 public: 17
19 PerfTestSuite(int argc, char** argv) : TestSuite(argc, argv) { 18 PerfTestSuite::PerfTestSuite(int argc, char** argv) : TestSuite(argc, argv) {
19 }
20
21 void PerfTestSuite::Initialize() {
22 TestSuite::Initialize();
23
24 // Initialize the perf timer log
25 FilePath log_path =
26 CommandLine::ForCurrentProcess()->GetSwitchValuePath("log-file");
27 if (log_path.empty()) {
28 FilePath exe;
29 PathService::Get(FILE_EXE, &exe);
30 log_path = exe.ReplaceExtension(FILE_PATH_LITERAL("log"));
31 log_path = log_path.InsertBeforeExtension(FILE_PATH_LITERAL("_perf"));
20 } 32 }
33 ASSERT_TRUE(InitPerfLog(log_path));
21 34
22 virtual void Initialize() { 35 // Raise to high priority to have more precise measurements. Since we don't
23 TestSuite::Initialize(); 36 // aim at 1% precision, it is not necessary to run at realtime level.
37 if (!DebugUtil::BeingDebugged())
38 RaiseProcessToHighPriority();
39 }
24 40
25 // Initialize the perf timer log 41 void PerfTestSuite::Shutdown() {
26 FilePath log_path = 42 TestSuite::Shutdown();
27 CommandLine::ForCurrentProcess()->GetSwitchValuePath("log-file"); 43 FinalizePerfLog();
28 if (log_path.empty()) { 44 }
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 45
36 // Raise to high priority to have more precise measurements. Since we don't 46 } // namespace base
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 };
48
49 #endif // BASE_TEST_PERF_TEST_SUITE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698