Make perftimer and run_all_perftests compile on Posix. Stub out a few things into process_util_posix, and add a function to raise to a high priority.
BUG=1343318 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1438 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -74,8 +74,8 @@ input_files = [
|
|||||||
'non_thread_safe.cc',
|
'non_thread_safe.cc',
|
||||||
'path_service.cc',
|
'path_service.cc',
|
||||||
'pickle.cc',
|
'pickle.cc',
|
||||||
'revocable_store.cc',
|
|
||||||
'ref_counted.cc',
|
'ref_counted.cc',
|
||||||
|
'revocable_store.cc',
|
||||||
'sha2.cc',
|
'sha2.cc',
|
||||||
'stats_table.cc',
|
'stats_table.cc',
|
||||||
'string_escape.cc',
|
'string_escape.cc',
|
||||||
@ -333,8 +333,10 @@ else:
|
|||||||
icudata = '../icudt38l.dat'
|
icudata = '../icudt38l.dat'
|
||||||
env.Alias('base', ['.', installed_base_unittests, icudata])
|
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.
|
# Since run_all_perftests supplies a main, we cannot have it in base.lib
|
||||||
if env['PLATFORM'] == 'win32':
|
env_tests.StaticObject('run_all_perftests.cc')
|
||||||
env_tests.StaticObject('perftimer.cc')
|
|
||||||
env_tests.StaticObject('run_all_perftests.cc')
|
|
||||||
|
@ -3,13 +3,11 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <shlwapi.h>
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include "base/perftimer.h"
|
#include "base/perftimer.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
|
#include "base/logging.h"
|
||||||
|
|
||||||
static FILE* perf_log_file = NULL;
|
static FILE* perf_log_file = NULL;
|
||||||
|
|
||||||
@ -20,7 +18,12 @@ bool InitPerfLog(const char* log_file) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
return fopen_s(&perf_log_file, log_file, "w") == 0;
|
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() {
|
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);
|
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);
|
printf("%s\t%g\t%s\n", test_name, value, units);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef BASE_PERFTTIMER_H__
|
#ifndef BASE_PERFTTIMER_H_
|
||||||
#define BASE_PERFTTIMER_H__
|
#define BASE_PERFTTIMER_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
@ -77,5 +77,4 @@ class PerfTimeLogger {
|
|||||||
PerfTimer timer_;
|
PerfTimer timer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BASE_PERFTTIMER_H__
|
#endif // BASE_PERFTTIMER_H_
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
typedef HANDLE ProcessHandle;
|
typedef HANDLE ProcessHandle;
|
||||||
#elif defined(OS_POSIX)
|
#elif defined(OS_POSIX)
|
||||||
|
// On POSIX, our ProcessHandle will just be the PID.
|
||||||
typedef int ProcessHandle;
|
typedef int ProcessHandle;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
// This file/namespace contains utility functions for enumerating, ending and
|
// This file/namespace contains utility functions for enumerating, ending and
|
||||||
// computing statistics of processes.
|
// computing statistics of processes.
|
||||||
|
|
||||||
#ifndef BASE_PROCESS_UTIL_H__
|
#ifndef BASE_PROCESS_UTIL_H_
|
||||||
#define BASE_PROCESS_UTIL_H__
|
#define BASE_PROCESS_UTIL_H_
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
|
|
||||||
@ -257,8 +257,10 @@ class ProcessMetrics {
|
|||||||
// Note: Returns true on Windows 2000 without doing anything.
|
// Note: Returns true on Windows 2000 without doing anything.
|
||||||
bool EnableLowFragmentationHeap();
|
bool EnableLowFragmentationHeap();
|
||||||
|
|
||||||
|
// If supported on the platform, and the user has sufficent rights, increase
|
||||||
|
// the current process's scheduling priority to a high priority.
|
||||||
|
void RaiseProcessToHighPriority();
|
||||||
|
|
||||||
} // namespace process_util
|
} // namespace process_util
|
||||||
|
|
||||||
|
#endif // BASE_PROCESS_UTIL_H_
|
||||||
#endif // BASE_PROCESS_UTIL_H__
|
|
||||||
|
|
||||||
|
@ -594,5 +594,8 @@ bool EnableLowFragmentationHeap() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace process_util
|
void RaiseProcessToHighPriority() {
|
||||||
|
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace process_util
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
|
#include "base/debug_util.h"
|
||||||
#include "base/perftimer.h"
|
#include "base/perftimer.h"
|
||||||
|
#include "base/process_util.h"
|
||||||
#include "base/string_util.h"
|
#include "base/string_util.h"
|
||||||
#include "base/test_suite.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
|
// 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.
|
// aim at 1% precision, it is not necessary to run at realtime level.
|
||||||
if (!IsDebuggerPresent())
|
if (!DebugUtil::BeingDebugged())
|
||||||
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
|
process_util::RaiseProcessToHighPriority();
|
||||||
|
|
||||||
TestSuite::Initialize();
|
TestSuite::Initialize();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user