• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "base/test/perf_test_suite.h"
6 
7 #include "base/command_line.h"
8 #include "base/debug/debugger.h"
9 #include "base/file_path.h"
10 #include "base/path_service.h"
11 #include "base/perftimer.h"
12 #include "base/process_util.h"
13 #include "base/string_util.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 
16 namespace base {
17 
PerfTestSuite(int argc,char ** argv)18 PerfTestSuite::PerfTestSuite(int argc, char** argv) : TestSuite(argc, argv) {
19 }
20 
Initialize()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(base::FILE_EXE, &exe);
30     log_path = exe.ReplaceExtension(FILE_PATH_LITERAL("log"));
31     log_path = log_path.InsertBeforeExtension(FILE_PATH_LITERAL("_perf"));
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 (!base::debug::BeingDebugged())
38     base::RaiseProcessToHighPriority();
39 }
40 
Shutdown()41 void PerfTestSuite::Shutdown() {
42   TestSuite::Shutdown();
43   FinalizePerfLog();
44 }
45 
46 }  // namespace base
47