More formatting tweaks

This commit is contained in:
Dominic Hamon 2014-01-09 12:19:02 -08:00
parent 78fa0b93ab
commit 5a71bd6e66
9 changed files with 55 additions and 57 deletions

View File

@ -165,7 +165,7 @@ void SetLabel(const std::string& label);
// computed by running the benchmark once with a single iteration and a memory
// tracer.)
// TODO(dominic)
//void MemoryUsage();
// void MemoryUsage();
// If a particular benchmark is I/O bound, or if for some reason CPU
// timings are not representative, call this method from within the
@ -303,7 +303,7 @@ class BenchmarkReporter {
struct Context {
int num_cpus;
double mhz_per_cpu;
//std::string cpu_info;
// std::string cpu_info;
bool cpu_scaling_enabled;
// The number of chars in the longest benchmark name.
@ -311,8 +311,8 @@ class BenchmarkReporter {
};
struct Run {
Run() :
thread_index(-1),
Run()
: thread_index(-1),
iterations(1),
real_accumulated_time(0),
cpu_accumulated_time(0),
@ -535,4 +535,3 @@ class ConsoleReporter : public BenchmarkReporter {
(new ::benchmark::internal::Benchmark(#n "<" #a "," #b ">", n<a, b>))
#endif // BENCHMARK_BENCHMARK_H_

View File

@ -298,16 +298,15 @@ void ComputeStats(const std::vector<BenchmarkReporter::Run>& reports,
namespace internal {
std::string ConsoleReporter::PrintMemoryUsage(double bytes) const {
if (!get_memory_usage || bytes < 0.0)
return "";
if (!get_memory_usage || bytes < 0.0) return "";
std::stringstream ss;
ss << " " << HumanReadableNumber(bytes) << "B peak-mem";
return ss.str();
}
bool ConsoleReporter::ReportContext(
const BenchmarkReporter::Context& context) const {
bool ConsoleReporter::ReportContext(const BenchmarkReporter::Context& context)
const {
name_field_width_ = context.name_field_width;
std::cout << "Benchmarking on " << context.num_cpus << " X "
@ -757,15 +756,15 @@ void Benchmark::FindBenchmarks(const std::string& spec,
} else if (family->rangeY_.empty()) {
for (size_t x = 0; x < family->rangeX_.size(); ++x) {
instances = family->CreateBenchmarkInstances(x, kNoRange);
benchmarks->insert(benchmarks->end(),
instances.begin(), instances.end());
benchmarks->insert(benchmarks->end(), instances.begin(),
instances.end());
}
} else {
for (size_t x = 0; x < family->rangeX_.size(); ++x) {
for (size_t y = 0; y < family->rangeY_.size(); ++y) {
instances = family->CreateBenchmarkInstances(x, y);
benchmarks->insert(benchmarks->end(),
instances.begin(), instances.end());
benchmarks->insert(benchmarks->end(), instances.begin(),
instances.end());
}
}
}
@ -1167,7 +1166,8 @@ void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter /*= nullptr*/) {
if (spec.empty() || spec == "all")
spec = "."; // Regexp that matches all benchmarks
internal::ConsoleReporter default_reporter;
internal::RunMatchingBenchmarks(spec, reporter == nullptr ? &default_reporter : reporter);
internal::RunMatchingBenchmarks(
spec, reporter == nullptr ? &default_reporter : reporter);
pthread_cond_destroy(&starting_cv);
pthread_mutex_destroy(&starting_mutex);
pthread_mutex_destroy(&benchmark_mutex);

View File

@ -108,4 +108,3 @@ void ColorPrintf(LogColor color, const char* fmt, ...) {
va_end(args);
}
} // end namespace benchmark

View File

@ -75,4 +75,3 @@ bool IsFlag(const char* str, const char* flag);
} // end namespace gbenchmark
#endif // BENCHMARK_COMMANDLINEFLAGS_H_

View File

@ -42,4 +42,3 @@ void SleepForSeconds(double seconds) {
}
#endif // OS_WINDOWS
} // end namespace benchmark

View File

@ -62,28 +62,28 @@ class Stat1 {
sum_squares_ = sum_ = VType();
}
Self& operator=(const Self &stat) {
Self &operator=(const Self &stat) {
sum_ = stat.sum_;
sum_squares_ = stat.sum_squares_;
numsamples_ = stat.numsamples_;
return (*this);
}
// Merge statistics from two sample sets.
Self& operator+=(const Self &stat) {
Self &operator+=(const Self &stat) {
sum_ += stat.sum_;
sum_squares_ += stat.sum_squares_;
numsamples_ += stat.numsamples_;
return (*this);
}
// The operation opposite to +=
Self& operator-=(const Self &stat) {
Self &operator-=(const Self &stat) {
sum_ -= stat.sum_;
sum_squares_ -= stat.sum_squares_;
numsamples_ -= stat.numsamples_;
return (*this);
}
// Multiply the weight of the set of samples by a factor k
Self& operator*=(const VType &k) {
Self &operator*=(const VType &k) {
sum_ *= k;
sum_squares_ *= k;
numsamples_ *= k;
@ -91,13 +91,13 @@ class Stat1 {
}
// Merge statistics from two sample sets.
Self operator+(const Self& stat) const { return Self(*this) += stat; }
Self operator+(const Self &stat) const { return Self(*this) += stat; }
// The operation opposite to +
Self operator-(const Self& stat) const { return Self(*this) -= stat; }
Self operator-(const Self &stat) const { return Self(*this) -= stat; }
// Multiply the weight of the set of samples by a factor k
Self operator*(const VType& k) const { return Self(*this) *= k; }
Self operator*(const VType &k) const { return Self(*this) *= k; }
// Return the total weight of this sample set
NumType numSamples() const { return numsamples_; }
@ -142,7 +142,9 @@ class Stat1 {
// Template function used to square a number.
// For a vector we square all components
template <typename SType>
static inline SType Sqr(const SType &dat) { return dat * dat; }
static inline SType Sqr(const SType &dat) {
return dat * dat;
}
template <typename SType>
static inline Vector2<SType> Sqr(const Vector2<SType> &dat) {
@ -189,7 +191,7 @@ class Stat1 {
// Useful printing function
template <typename VType, typename NumType>
std::ostream& operator<<(std::ostream& out, const Stat1<VType, NumType>& s) {
std::ostream &operator<<(std::ostream &out, const Stat1<VType, NumType> &s) {
out << "{ avg = " << s.Mean() << " std = " << s.StdDev()
<< " nsamples = " << s.NumSamples() << "}";
return out;
@ -214,7 +216,7 @@ class Stat1MinMax : public Stat1<VType, NumType> {
// and end(excluded)
explicit Stat1MinMax(const VType *begin, const VType *end) {
Clear();
for (const VType* item = begin; item < end; ++item) {
for (const VType *item = begin; item < end; ++item) {
(*this) += Stat1MinMax(*item);
}
}
@ -241,28 +243,28 @@ class Stat1MinMax : public Stat1<VType, NumType> {
}
}
Self& operator=(const Self& stat) {
Self &operator=(const Self &stat) {
this->Stat1<VType, NumType>::operator=(stat);
max_ = stat.max_;
min_ = stat.min_;
return (*this);
}
// Merge statistics from two sample sets.
Self& operator+=(const Self& stat) {
Self &operator+=(const Self &stat) {
this->Stat1<VType, NumType>::operator+=(stat);
if (stat.max_ > max_) max_ = stat.max_;
if (stat.min_ < min_) min_ = stat.min_;
return (*this);
}
// Multiply the weight of the set of samples by a factor k
Self& operator*=(const VType& stat) {
Self &operator*=(const VType &stat) {
this->Stat1<VType, NumType>::operator*=(stat);
return (*this);
}
// Merge statistics from two sample sets.
Self operator+(const Self& stat) const { return Self(*this) += stat; }
Self operator+(const Self &stat) const { return Self(*this) += stat; }
// Multiply the weight of the set of samples by a factor k
Self operator*(const VType& k) const { return Self(*this) *= k; }
Self operator*(const VType &k) const { return Self(*this) *= k; }
// Return the maximal value in this sample set
VType max() const { return max_; }
@ -273,10 +275,10 @@ class Stat1MinMax : public Stat1<VType, NumType> {
// The - operation makes no sense with Min/Max
// unless we keep the full list of values (but we don't)
// make it private, and let it undefined so nobody can call it
Self &operator-=(const Self& stat); // senseless. let it undefined.
Self &operator-=(const Self &stat); // senseless. let it undefined.
// The operation opposite to -
Self operator-(const Self& stat) const; // senseless. let it undefined.
Self operator-(const Self &stat) const; // senseless. let it undefined.
// Let i be the index of the samples provided (using +=)
// and weight[i],value[i] be the data of sample #i
@ -287,8 +289,8 @@ class Stat1MinMax : public Stat1<VType, NumType> {
// Useful printing function
template <typename VType, typename NumType>
std::ostream& operator<<(std::ostream& out,
const Stat1MinMax<VType, NumType>& s) {
std::ostream &operator<<(std::ostream &out,
const Stat1MinMax<VType, NumType> &s) {
out << "{ avg = " << s.Mean() << " std = " << s.StdDev()
<< " nsamples = " << s.NumSamples() << " min = " << s.Min()
<< " max = " << s.Max() << "}";

View File

@ -208,7 +208,7 @@ void InitializeSystemInfo() {
unsigned int hz = 0;
#endif
size_t sz = sizeof(hz);
const char *sysctl_path = "machdep.tsc_freq";
const char* sysctl_path = "machdep.tsc_freq";
if (sysctlbyname(sysctl_path, &hz, &sz, NULL, 0) != 0) {
fprintf(stderr, "Unable to determine clock rate from sysctl: %s: %s\n",
sysctl_path, strerror(errno));
@ -233,7 +233,7 @@ void InitializeSystemInfo() {
cpuinfo_cycles_per_second = (int64)data * (int64)(1000 * 1000); // was mhz
else
cpuinfo_cycles_per_second = EstimateCyclesPerSecond();
// TODO: also figure out cpuinfo_num_cpus
// TODO: also figure out cpuinfo_num_cpus
#elif defined OS_MACOSX
// returning "mach time units" per second. the current number of elapsed