mirror of
https://github.com/google/benchmark.git
synced 2025-04-02 15:40:53 +08:00
move interface closer
This commit is contained in:
parent
0a26e0337c
commit
671b16e34f
@ -32,6 +32,10 @@
|
||||
|
||||
namespace benchmark {
|
||||
|
||||
inline void SetLabel(std::string const& label) {
|
||||
SetLabel(label.c_str());
|
||||
}
|
||||
|
||||
class Benchmark {
|
||||
public:
|
||||
// The Benchmark takes ownership of the Callback pointed to by f.
|
||||
|
@ -169,12 +169,24 @@ void RunSpecifiedBenchmarks(BenchmarkReporter* reporter = NULL);
|
||||
// ------------------------------------------------------
|
||||
// Routines that can be called from within a benchmark
|
||||
|
||||
//
|
||||
// REQUIRES: a benchmark is currently executing
|
||||
// NOTE: SetLabel(std::string const &) is available in benchmark.h
|
||||
void SetLabel(const char* label);
|
||||
|
||||
// If a particular benchmark is I/O bound, or if for some reason CPU
|
||||
// timings are not representative, call this method from within the
|
||||
// benchmark routine. If called, the elapsed time will be used to
|
||||
// control how many iterations are run, and in the printing of
|
||||
// items/second or MB/seconds values. If not called, the cpu time
|
||||
// used by the benchmark will be used.
|
||||
void UseRealTime();
|
||||
|
||||
|
||||
namespace internal {
|
||||
|
||||
void SetBenchmarkLabel(const char* label);
|
||||
void StartBenchmarkTiming();
|
||||
void StopBenchmarkTiming();
|
||||
void BenchmarkUseRealTime();
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
@ -249,17 +261,6 @@ public:
|
||||
internal::StartBenchmarkTiming();
|
||||
}
|
||||
|
||||
// If a particular benchmark is I/O bound, or if for some reason CPU
|
||||
// timings are not representative, call this method from within the
|
||||
// benchmark routine. If called, the elapsed time will be used to
|
||||
// control how many iterations are run, and in the printing of
|
||||
// items/second or MB/seconds values. If not called, the cpu time
|
||||
// used by the benchmark will be used.
|
||||
BENCHMARK_ALWAYS_INLINE
|
||||
void UseRealTime() {
|
||||
internal::BenchmarkUseRealTime();
|
||||
}
|
||||
|
||||
// Set the number of bytes processed by the current benchmark
|
||||
// execution. This routine is typically called once at the end of a
|
||||
// throughput oriented benchmark. If this routine is called with a
|
||||
@ -307,7 +308,7 @@ public:
|
||||
// REQUIRES: a benchmark has exited its KeepRunning loop.
|
||||
BENCHMARK_ALWAYS_INLINE
|
||||
void SetLabel(const char* label) {
|
||||
internal::SetBenchmarkLabel(label);
|
||||
::benchmark::SetLabel(label);
|
||||
}
|
||||
|
||||
// Range arguments for this run. CHECKs if the argument has been set.
|
||||
|
@ -876,14 +876,20 @@ void RunSpecifiedBenchmarks(BenchmarkReporter* reporter) {
|
||||
}
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
void SetBenchmarkLabel(const char* label) {
|
||||
void SetLabel(const char* label) {
|
||||
CHECK(running_benchmark);
|
||||
MutexLock l(GetBenchmarkLock());
|
||||
report_label = label;
|
||||
}
|
||||
|
||||
void UseRealTime() {
|
||||
MutexLock l(GetBenchmarkLock());
|
||||
use_real_time = true;
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
void StopBenchmarkTiming() {
|
||||
// Add in time accumulated so far
|
||||
CHECK(running_benchmark);
|
||||
@ -895,12 +901,6 @@ void StartBenchmarkTiming() {
|
||||
timer_manager->StartTimer();
|
||||
}
|
||||
|
||||
|
||||
void BenchmarkUseRealTime() {
|
||||
MutexLock l(GetBenchmarkLock());
|
||||
use_real_time = true;
|
||||
}
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
void PrintUsageAndExit() {
|
||||
|
Loading…
Reference in New Issue
Block a user