OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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/at_exit.h" | |
6 #include "base/command_line.h" | |
7 #include "base/debug_util.h" | |
8 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
9 #include "base/perftimer.h" | 6 #include "base/perf_test_suite.h" |
10 #include "base/process_util.h" | |
11 #include "chrome/common/chrome_paths.cc" | 7 #include "chrome/common/chrome_paths.cc" |
12 #include "testing/gtest/include/gtest/gtest.h" | |
13 | |
14 // TODO(darin): share code with base/run_all_perftests.cc | |
15 | 8 |
16 int main(int argc, char **argv) { | 9 int main(int argc, char **argv) { |
17 base::AtExitManager exit_manager; | |
18 base::EnableTerminationOnHeapCorruption(); | |
19 CommandLine::SetArgcArgv(argc, argv); | |
20 chrome::RegisterPathProvider(); | 10 chrome::RegisterPathProvider(); |
21 MessageLoop main_message_loop; | 11 MessageLoop main_message_loop; |
22 | 12 |
23 testing::InitGoogleTest(&argc, argv); | 13 return PerfTestSuite(argc, argv).Run(); |
24 | |
25 const char log_file_switch[] = "-o"; | |
26 const char* log_filename = NULL; | |
27 for (int i = 1; i < argc; i++) { | |
28 if (strcmp(argv[i], log_file_switch) == 0) { | |
29 // found the switch for the log file, use the next arg | |
30 if (i >= argc - 1) { | |
31 fprintf(stderr, "Log file not specified"); | |
32 return 1; | |
33 } | |
34 log_filename = argv[i + 1]; | |
35 } | |
36 } | |
37 if (!log_filename) { | |
38 // use the default filename | |
39 log_filename = "perf_test.log"; | |
40 } | |
41 printf("Using output file \"%s\" (change with %s <filename>)\n", | |
42 log_filename, log_file_switch); | |
43 | |
44 if (!InitPerfLog(log_filename)) { | |
45 fprintf(stderr, "Unable to open log file\n"); | |
46 return 1; | |
47 } | |
48 | |
49 // Raise to high priority to have more precise measurements. Since we don't | |
50 // aim at 1% precision, it is not necessary to run at realtime level. | |
51 if (!DebugUtil::BeingDebugged()) { | |
52 base::RaiseProcessToHighPriority(); | |
53 } | |
54 | |
55 int result = RUN_ALL_TESTS(); | |
56 | |
57 FinalizePerfLog(); | |
58 return result; | |
59 } | 14 } |
60 | 15 |
OLD | NEW |