Commit 80093519 by Dominic Hamon

Minimum iteration and overhead support.

Ensure we run at least 1 iteration. Take into account overhead of an empty benchmark. Minor cleanup of code.
parent 2ff306af
...@@ -155,7 +155,7 @@ std::string ToBinaryStringFullySpecified(double value, double threshold, ...@@ -155,7 +155,7 @@ std::string ToBinaryStringFullySpecified(double value, double threshold,
int precision) { int precision) {
std::string mantissa; std::string mantissa;
int exponent; int exponent;
ToExponentAndMantissa(value, threshold, precision, 1024., &mantissa, ToExponentAndMantissa(value, threshold, precision, 1024.0, &mantissa,
&exponent); &exponent);
return mantissa + ExponentToPrefix(exponent, false); return mantissa + ExponentToPrefix(exponent, false);
} }
...@@ -209,7 +209,7 @@ const char* Prefix() { ...@@ -209,7 +209,7 @@ const char* Prefix() {
// TODO // TODO
//static internal::MallocCounter *benchmark_mc; //static internal::MallocCounter *benchmark_mc;
static bool CpuScalingEnabled() { bool CpuScalingEnabled() {
// On Linux, the CPUfreq subsystem exposes CPU information as files on the // On Linux, the CPUfreq subsystem exposes CPU information as files on the
// local file system. If reading the exported files fails, then we may not be // local file system. If reading the exported files fails, then we may not be
// running on Linux, so we silently ignore all the read errors. // running on Linux, so we silently ignore all the read errors.
...@@ -523,16 +523,17 @@ namespace internal { ...@@ -523,16 +523,17 @@ namespace internal {
// Information kept per benchmark we may want to run // Information kept per benchmark we may want to run
struct Benchmark::Instance { struct Benchmark::Instance {
Instance() Instance()
: rangeXset(false), rangeX(kNoRange), : bm(nullptr), threads(1), rangeXset(false), rangeX(kNoRange),
rangeYset(false), rangeY(kNoRange) {} rangeYset(false), rangeY(kNoRange) {}
std::string name; std::string name;
Benchmark* bm; Benchmark* bm;
int threads; // Number of concurrent threads to use
bool rangeXset; bool rangeXset;
int rangeX; int rangeX;
bool rangeYset; bool rangeYset;
int rangeY; int rangeY;
int threads; // Number of concurrent threads to use
bool multithreaded() const { return !bm->thread_counts_.empty(); } bool multithreaded() const { return !bm->thread_counts_.empty(); }
}; };
...@@ -682,9 +683,7 @@ std::vector<Benchmark::Instance> Benchmark::CreateBenchmarkInstances( ...@@ -682,9 +683,7 @@ std::vector<Benchmark::Instance> Benchmark::CreateBenchmarkInstances(
const bool is_multithreaded = (!thread_counts_.empty()); const bool is_multithreaded = (!thread_counts_.empty());
const std::vector<int>& thread_counts = const std::vector<int>& thread_counts =
(is_multithreaded ? thread_counts_ : one_thread); (is_multithreaded ? thread_counts_ : one_thread);
for (size_t t = 0; t < thread_counts.size(); ++t) { for (int num_threads : thread_counts) {
int num_threads = thread_counts[t];
Instance instance; Instance instance;
instance.name = name_; instance.name = name_;
instance.bm = this; instance.bm = this;
...@@ -1002,8 +1001,10 @@ void State::NewInterval() { ...@@ -1002,8 +1001,10 @@ void State::NewInterval() {
} }
bool State::FinishInterval() { bool State::FinishInterval() {
if (FLAGS_benchmark_iterations != 0 && if ((FLAGS_benchmark_iterations != 0 &&
iterations_ < FLAGS_benchmark_iterations / FLAGS_benchmark_repetitions) { iterations_ <
FLAGS_benchmark_iterations / FLAGS_benchmark_repetitions) ||
iterations_ < 1) {
interval_micros_ *= 2; interval_micros_ *= 2;
#ifdef DEBUG #ifdef DEBUG
std::cout << "Not enough iterations in interval; " std::cout << "Not enough iterations in interval; "
...@@ -1020,7 +1021,8 @@ bool State::FinishInterval() { ...@@ -1020,7 +1021,8 @@ bool State::FinishInterval() {
data.thread_index = thread_index; data.thread_index = thread_index;
const double accumulated_time = walltime::Now() - start_time_; const double accumulated_time = walltime::Now() - start_time_;
const double total_overhead = 0.0; // TODO: overhead * iterations_; const double total_overhead = overhead * iterations_;
//const double total_overhead = 0.0;
CHECK_LT(pause_time_, accumulated_time); CHECK_LT(pause_time_, accumulated_time);
CHECK_LT(pause_time_ + total_overhead, accumulated_time); CHECK_LT(pause_time_ + total_overhead, accumulated_time);
data.real_accumulated_time = data.real_accumulated_time =
......
...@@ -53,7 +53,7 @@ void ColorPrintf(LogColor color, const char* fmt, ...) { ...@@ -53,7 +53,7 @@ void ColorPrintf(LogColor color, const char* fmt, ...) {
#ifdef OS_WINDOWS #ifdef OS_WINDOWS
const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
// Gets the current text color. // Gets the current text color.
CONSOLE_SCREEN_BUFFER_INFO buffer_info; CONSOLE_SCREEN_BUFFER_INFO buffer_info;
GetConsoleScreenBufferInfo(stdout_handle, &buffer_info); GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment