summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/SConscript12
-rw-r--r--base/perftimer.cc11
-rw-r--r--base/perftimer.h7
-rw-r--r--base/process.h1
-rw-r--r--base/process_util.h12
-rw-r--r--base/process_util_win.cc5
-rw-r--r--base/run_all_perftests.cc8
7 files changed, 32 insertions, 24 deletions
diff --git a/base/SConscript b/base/SConscript
index c754dc7..b08d5db 100644
--- a/base/SConscript
+++ b/base/SConscript
@@ -74,8 +74,8 @@ input_files = [
'non_thread_safe.cc',
'path_service.cc',
'pickle.cc',
- 'revocable_store.cc',
'ref_counted.cc',
+ 'revocable_store.cc',
'sha2.cc',
'stats_table.cc',
'string_escape.cc',
@@ -333,8 +333,10 @@ else:
icudata = '../icudt38l.dat'
env.Alias('base', ['.', installed_base_unittests, icudata])
+# TODO(sgk) should this be moved into base.lib like everything else? This will
+# require updating a bunch of other SConscripts which link directly against
+# this generated object file.
+env_tests.StaticObject('perftimer.cc')
-# These aren't ported to other platforms yet.
-if env['PLATFORM'] == 'win32':
- env_tests.StaticObject('perftimer.cc')
- env_tests.StaticObject('run_all_perftests.cc')
+# Since run_all_perftests supplies a main, we cannot have it in base.lib
+env_tests.StaticObject('run_all_perftests.cc')
diff --git a/base/perftimer.cc b/base/perftimer.cc
index 4f31e55..1231923 100644
--- a/base/perftimer.cc
+++ b/base/perftimer.cc
@@ -3,13 +3,11 @@
// found in the LICENSE file.
#include <stdio.h>
-#include <shlwapi.h>
-#include <windows.h>
#include "base/perftimer.h"
-#include "base/logging.h"
#include "base/basictypes.h"
+#include "base/logging.h"
static FILE* perf_log_file = NULL;
@@ -20,7 +18,12 @@ bool InitPerfLog(const char* log_file) {
return false;
}
+#if defined(OS_WIN)
return fopen_s(&perf_log_file, log_file, "w") == 0;
+#elif defined(OS_POSIX)
+ perf_log_file = fopen(log_file, "w");
+ return perf_log_file != NULL;
+#endif
}
void FinalizePerfLog() {
@@ -41,5 +44,3 @@ void LogPerfResult(const char* test_name, double value, const char* units) {
fprintf(perf_log_file, "%s\t%g\t%s\n", test_name, value, units);
printf("%s\t%g\t%s\n", test_name, value, units);
}
-
-
diff --git a/base/perftimer.h b/base/perftimer.h
index 1b40e66..86314e9 100644
--- a/base/perftimer.h
+++ b/base/perftimer.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef BASE_PERFTTIMER_H__
-#define BASE_PERFTTIMER_H__
+#ifndef BASE_PERFTTIMER_H_
+#define BASE_PERFTTIMER_H_
#include <string>
#include "base/basictypes.h"
@@ -77,5 +77,4 @@ class PerfTimeLogger {
PerfTimer timer_;
};
-#endif // BASE_PERFTTIMER_H__
-
+#endif // BASE_PERFTTIMER_H_
diff --git a/base/process.h b/base/process.h
index 8b54fb2..2a92fcd 100644
--- a/base/process.h
+++ b/base/process.h
@@ -16,6 +16,7 @@
#if defined(OS_WIN)
typedef HANDLE ProcessHandle;
#elif defined(OS_POSIX)
+// On POSIX, our ProcessHandle will just be the PID.
typedef int ProcessHandle;
#endif
diff --git a/base/process_util.h b/base/process_util.h
index 978da42..6c26a402 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -5,8 +5,8 @@
// This file/namespace contains utility functions for enumerating, ending and
// computing statistics of processes.
-#ifndef BASE_PROCESS_UTIL_H__
-#define BASE_PROCESS_UTIL_H__
+#ifndef BASE_PROCESS_UTIL_H_
+#define BASE_PROCESS_UTIL_H_
#include "base/basictypes.h"
@@ -257,8 +257,10 @@ class ProcessMetrics {
// Note: Returns true on Windows 2000 without doing anything.
bool EnableLowFragmentationHeap();
-} // namespace process_util
-
+// If supported on the platform, and the user has sufficent rights, increase
+// the current process's scheduling priority to a high priority.
+void RaiseProcessToHighPriority();
-#endif // BASE_PROCESS_UTIL_H__
+} // namespace process_util
+#endif // BASE_PROCESS_UTIL_H_
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index f09228fb..aad336cf 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -594,5 +594,8 @@ bool EnableLowFragmentationHeap() {
return true;
}
-} // namespace process_util
+void RaiseProcessToHighPriority() {
+ SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+}
+} // namespace process_util
diff --git a/base/run_all_perftests.cc b/base/run_all_perftests.cc
index 967aeb9..1ecf8d1 100644
--- a/base/run_all_perftests.cc
+++ b/base/run_all_perftests.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <windows.h>
-
#include "base/command_line.h"
+#include "base/debug_util.h"
#include "base/perftimer.h"
+#include "base/process_util.h"
#include "base/string_util.h"
#include "base/test_suite.h"
@@ -24,8 +24,8 @@ class PerfTestSuite : public TestSuite {
// 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 (!IsDebuggerPresent())
- SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+ if (!DebugUtil::BeingDebugged())
+ process_util::RaiseProcessToHighPriority();
TestSuite::Initialize();
}