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