diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index 45ab35b8..293678c5 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -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,14 +311,14 @@ class BenchmarkReporter { }; struct Run { - Run() : - thread_index(-1), - iterations(1), - real_accumulated_time(0), - cpu_accumulated_time(0), - bytes_per_second(0), - items_per_second(0), - max_heapbytes_used(0) {} + Run() + : thread_index(-1), + iterations(1), + real_accumulated_time(0), + cpu_accumulated_time(0), + bytes_per_second(0), + items_per_second(0), + max_heapbytes_used(0) {} std::string benchmark_name; std::string report_label; @@ -535,4 +535,3 @@ class ConsoleReporter : public BenchmarkReporter { (new ::benchmark::internal::Benchmark(#n "<" #a "," #b ">", n)) #endif // BENCHMARK_BENCHMARK_H_ - diff --git a/src/benchmark.cc b/src/benchmark.cc index e5781c92..e24b34b9 100644 --- a/src/benchmark.cc +++ b/src/benchmark.cc @@ -298,16 +298,15 @@ void ComputeStats(const std::vector& 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 " @@ -404,7 +403,7 @@ void PrintUsageAndExit() { "benchmark [--benchmark_filter=]\n" " [--benchmark_iterations=]\n" " [--benchmark_min_time=]\n" - //" [--benchmark_memory_usage]\n" + //" [--benchmark_memory_usage]\n" " [--benchmark_repetitions=]\n" " [--color_print={true|false}]\n" " [--v=]\n"); @@ -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); diff --git a/src/colorprint.cc b/src/colorprint.cc index c604f83d..3a84f6ac 100644 --- a/src/colorprint.cc +++ b/src/colorprint.cc @@ -1,11 +1,11 @@ // Copyright 2014 Google Inc. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -108,4 +108,3 @@ void ColorPrintf(LogColor color, const char* fmt, ...) { va_end(args); } } // end namespace benchmark - diff --git a/src/commandlineflags.cc b/src/commandlineflags.cc index 6ea80f25..57a75f5a 100644 --- a/src/commandlineflags.cc +++ b/src/commandlineflags.cc @@ -1,11 +1,11 @@ // Copyright 2014 Google Inc. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/commandlineflags.h b/src/commandlineflags.h index 9875d88f..001c8bac 100644 --- a/src/commandlineflags.h +++ b/src/commandlineflags.h @@ -75,4 +75,3 @@ bool IsFlag(const char* str, const char* flag); } // end namespace gbenchmark #endif // BENCHMARK_COMMANDLINEFLAGS_H_ - diff --git a/src/sleep.cc b/src/sleep.cc index f6d3ce81..a6bce1d1 100644 --- a/src/sleep.cc +++ b/src/sleep.cc @@ -1,11 +1,11 @@ // Copyright 2014 Google Inc. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,4 +42,3 @@ void SleepForSeconds(double seconds) { } #endif // OS_WINDOWS } // end namespace benchmark - diff --git a/src/stat.h b/src/stat.h index 1a726d28..b556309e 100644 --- a/src/stat.h +++ b/src/stat.h @@ -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 - static inline SType Sqr(const SType &dat) { return dat * dat; } + static inline SType Sqr(const SType &dat) { + return dat * dat; + } template static inline Vector2 Sqr(const Vector2 &dat) { @@ -189,7 +191,7 @@ class Stat1 { // Useful printing function template -std::ostream& operator<<(std::ostream& out, const Stat1& s) { +std::ostream &operator<<(std::ostream &out, const Stat1 &s) { out << "{ avg = " << s.Mean() << " std = " << s.StdDev() << " nsamples = " << s.NumSamples() << "}"; return out; @@ -214,7 +216,7 @@ class Stat1MinMax : public Stat1 { // 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 { } } - Self& operator=(const Self& stat) { + Self &operator=(const Self &stat) { this->Stat1::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::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::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 { // 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 { // Useful printing function template -std::ostream& operator<<(std::ostream& out, - const Stat1MinMax& s) { +std::ostream &operator<<(std::ostream &out, + const Stat1MinMax &s) { out << "{ avg = " << s.Mean() << " std = " << s.StdDev() << " nsamples = " << s.NumSamples() << " min = " << s.Min() << " max = " << s.Max() << "}"; diff --git a/src/sysinfo.cc b/src/sysinfo.cc index 8fadf7e1..5a4777a1 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -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 diff --git a/src/walltime.cc b/src/walltime.cc index b57913b2..52bab354 100644 --- a/src/walltime.cc +++ b/src/walltime.cc @@ -1,11 +1,11 @@ // Copyright 2014 Google Inc. All rights reserved. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.