You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by zu...@apache.org on 2017/01/29 02:15:59 UTC
[49/53] [partial] incubator-quickstep git commit: Make the third
party directory leaner.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/benchmark.cc
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/benchmark.cc b/third_party/benchmark/src/benchmark.cc
deleted file mode 100644
index d4f6f1b..0000000
--- a/third_party/benchmark/src/benchmark.cc
+++ /dev/null
@@ -1,1188 +0,0 @@
-// Copyright 2015 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.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "benchmark/benchmark.h"
-#include "arraysize.h"
-#include "check.h"
-#include "colorprint.h"
-#include "commandlineflags.h"
-#include "internal_macros.h"
-#include "log.h"
-#include "re.h"
-#include "sleep.h"
-#include "stat.h"
-#include "string_util.h"
-#include "sysinfo.h"
-#include "walltime.h"
-
-#include <sys/time.h>
-#include <string.h>
-
-#include <algorithm>
-#include <atomic>
-#include <condition_variable>
-#include <iostream>
-#include <memory>
-#include <mutex>
-#include <thread>
-#include <sstream>
-
-DEFINE_string(benchmark_filter, ".",
- "A regular expression that specifies the set of benchmarks "
- "to execute. If this flag is empty, no benchmarks are run. "
- "If this flag is the string \"all\", all benchmarks linked "
- "into the process are run.");
-
-DEFINE_int32(benchmark_iterations, 0,
- "Total number of iterations per benchmark. 0 means the benchmarks "
- "are time-based.");
-
-DEFINE_double(benchmark_min_time, 0.5,
- "Minimum number of seconds we should run benchmark before "
- "results are considered significant. For cpu-time based "
- "tests, this is the lower bound on the total cpu time "
- "used by all threads that make up the test. For real-time "
- "based tests, this is the lower bound on the elapsed time "
- "of the benchmark execution, regardless of number of "
- "threads.");
-
-DEFINE_bool(benchmark_memory_usage, false,
- "Report memory usage for all benchmarks");
-
-DEFINE_int32(benchmark_repetitions, 1,
- "The number of runs of each benchmark. If greater than 1, the "
- "mean and standard deviation of the runs will be reported.");
-
-DEFINE_int32(v, 0, "The level of verbose logging to output");
-DEFINE_bool(color_print, true, "Enables colorized logging.");
-
-// Will be non-empty if heap checking is turned on, which would
-// invalidate any benchmarks.
-DECLARE_string(heap_check);
-
-// The ""'s catch people who don't pass in a literal for "str"
-#define strliterallen(str) (sizeof("" str "") - 1)
-
-// Must use a string literal for prefix.
-#define memprefix(str, len, prefix) \
- ((((len) >= strliterallen(prefix)) && \
- memcmp(str, prefix, strliterallen(prefix)) == 0) \
- ? str + strliterallen(prefix) \
- : NULL)
-
-namespace benchmark {
-namespace {
-// For non-dense Range, intermediate values are powers of kRangeMultiplier.
-static const int kRangeMultiplier = 8;
-
-std::mutex starting_mutex;
-std::condition_variable starting_cv;
-
-bool running_benchmark = false;
-
-// Should this benchmark report memory usage?
-bool get_memory_usage;
-
-// Should this benchmark base decisions off of real time rather than
-// cpu time?
-bool use_real_time;
-
-// Overhead of an empty benchmark.
-double overhead = 0.0;
-
-// Return prefix to print in front of each reported line
-const char* Prefix() {
-#ifdef NDEBUG
- return "";
-#else
- return "DEBUG: ";
-#endif
-}
-
-// TODO
-// static internal::MallocCounter *benchmark_mc;
-
-bool CpuScalingEnabled() {
- // 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
- // running on Linux, so we silently ignore all the read errors.
- for (int cpu = 0, num_cpus = NumCPUs(); cpu < num_cpus; ++cpu) {
- std::stringstream ss;
- ss << "/sys/devices/system/cpu/cpu" << cpu << "/cpufreq/scaling_governor";
- std::string governor_file = ss.str();
- FILE* file = fopen(governor_file.c_str(), "r");
- if (!file) break;
- char buff[16];
- size_t bytes_read = fread(buff, 1, sizeof(buff), file);
- fclose(file);
- if (memprefix(buff, bytes_read, "performance") == NULL) return true;
- }
- return false;
-}
-
-// Given a collection of reports, computes their mean and stddev.
-// REQUIRES: all runs in "reports" must be from the same benchmark.
-void ComputeStats(const std::vector<BenchmarkReporter::Run>& reports,
- BenchmarkReporter::Run* mean_data,
- BenchmarkReporter::Run* stddev_data) {
- // Accumulators.
- Stat1_d real_accumulated_time_stat;
- Stat1_d cpu_accumulated_time_stat;
- Stat1_d items_per_second_stat;
- Stat1_d bytes_per_second_stat;
- Stat1_d iterations_stat;
- Stat1MinMax_d max_heapbytes_used_stat;
-
- // Populate the accumulators.
- for (std::vector<BenchmarkReporter::Run>::const_iterator it = reports.begin();
- it != reports.end(); ++it) {
- CHECK_EQ(reports[0].benchmark_name, it->benchmark_name);
- real_accumulated_time_stat +=
- Stat1_d(it->real_accumulated_time / it->iterations, it->iterations);
- cpu_accumulated_time_stat +=
- Stat1_d(it->cpu_accumulated_time / it->iterations, it->iterations);
- items_per_second_stat += Stat1_d(it->items_per_second, it->iterations);
- bytes_per_second_stat += Stat1_d(it->bytes_per_second, it->iterations);
- iterations_stat += Stat1_d(it->iterations, it->iterations);
- max_heapbytes_used_stat +=
- Stat1MinMax_d(it->max_heapbytes_used, it->iterations);
- }
-
- // Get the data from the accumulator to BenchmarkRunData's. In the
- // computations below we must multiply by the number of iterations since
- // PrintRunData will divide by it.
- mean_data->benchmark_name = reports[0].benchmark_name + "_mean";
- mean_data->iterations = iterations_stat.Mean();
- mean_data->real_accumulated_time = real_accumulated_time_stat.Mean() *
- mean_data->iterations;
- mean_data->cpu_accumulated_time = cpu_accumulated_time_stat.Mean() *
- mean_data->iterations;
- mean_data->bytes_per_second = bytes_per_second_stat.Mean();
- mean_data->items_per_second = items_per_second_stat.Mean();
- mean_data->max_heapbytes_used = max_heapbytes_used_stat.Max();
-
- // Only add label to mean/stddev if it is same for all runs
- mean_data->report_label = reports[0].report_label;
- for (size_t i = 1; i < reports.size(); i++) {
- if (reports[i].report_label != reports[0].report_label) {
- mean_data->report_label = "";
- break;
- }
- }
-
- stddev_data->benchmark_name = reports[0].benchmark_name + "_stddev";
- stddev_data->report_label = mean_data->report_label;
- stddev_data->iterations = iterations_stat.StdDev();
- // The value of iterations_stat.StdDev() above may be 0 if all the repetitions
- // have the same number of iterations. Blindly multiplying by 0 in the
- // computation of real/cpu_accumulated_time below would lead to 0/0 in
- // PrintRunData. So we skip the multiplication in this case and PrintRunData
- // skips the division.
- if (stddev_data->iterations == 0) {
- stddev_data->real_accumulated_time = real_accumulated_time_stat.StdDev();
- stddev_data->cpu_accumulated_time = cpu_accumulated_time_stat.StdDev();
- } else {
- stddev_data->real_accumulated_time = real_accumulated_time_stat.StdDev() *
- stddev_data->iterations;
- stddev_data->cpu_accumulated_time = cpu_accumulated_time_stat.StdDev() *
- stddev_data->iterations;
- }
- stddev_data->bytes_per_second = bytes_per_second_stat.StdDev();
- stddev_data->items_per_second = items_per_second_stat.StdDev();
- stddev_data->max_heapbytes_used = max_heapbytes_used_stat.StdDev();
-}
-} // namespace
-
-namespace internal {
-
-// Class for managing registered benchmarks. Note that each registered
-// benchmark identifies a family of related benchmarks to run.
-class BenchmarkFamilies {
- public:
- static BenchmarkFamilies* GetInstance();
-
- // Registers a benchmark family and returns the index assigned to it.
- size_t AddBenchmark(Benchmark* family);
-
- // Unregisters a family at the given index.
- void RemoveBenchmark(size_t index);
-
- // Extract the list of benchmark instances that match the specified
- // regular expression.
- void FindBenchmarks(const std::string& re,
- std::vector<Benchmark::Instance>* benchmarks);
- private:
- BenchmarkFamilies();
- ~BenchmarkFamilies();
-
- std::vector<Benchmark*> families_;
- std::mutex mutex_;
-};
-
-BenchmarkFamilies* BenchmarkFamilies::GetInstance() {
- static BenchmarkFamilies instance;
- return &instance;
-}
-
-BenchmarkFamilies::BenchmarkFamilies() { }
-
-BenchmarkFamilies::~BenchmarkFamilies() {
- for (internal::Benchmark* family : families_) {
- delete family;
- }
-}
-
-size_t BenchmarkFamilies::AddBenchmark(Benchmark* family) {
- std::lock_guard<std::mutex> l(mutex_);
- // This loop attempts to reuse an entry that was previously removed to avoid
- // unncessary growth of the vector.
- for (size_t index = 0; index < families_.size(); ++index) {
- if (families_[index] == nullptr) {
- families_[index] = family;
- return index;
- }
- }
- size_t index = families_.size();
- families_.push_back(family);
- return index;
-}
-
-void BenchmarkFamilies::RemoveBenchmark(size_t index) {
- std::lock_guard<std::mutex> l(mutex_);
- families_[index] = NULL;
- // Don't shrink families_ here, we might be called by the destructor of
- // BenchmarkFamilies which iterates over the vector.
-}
-
-void BenchmarkFamilies::FindBenchmarks(
- const std::string& spec,
- std::vector<Benchmark::Instance>* benchmarks) {
- // Make regular expression out of command-line flag
- Regex re;
- std::string re_error;
- if (!re.Init(spec, &re_error)) {
- std::cerr << "Could not compile benchmark re: " << re_error << std::endl;
- return;
- }
-
- std::lock_guard<std::mutex> l(mutex_);
- for (internal::Benchmark* family : families_) {
- if (family == nullptr) continue; // Family was deleted
-
- // Match against filter.
- if (!re.Match(family->name_)) {
- VLOG(1) << "Skipping " << family->name_ << "\n";
- continue;
- }
-
- std::vector<Benchmark::Instance> instances;
- if (family->rangeX_.empty() && family->rangeY_.empty()) {
- instances = family->CreateBenchmarkInstances(
- Benchmark::kNoRangeIndex, Benchmark::kNoRangeIndex);
- std::copy(instances.begin(), instances.end(),
- std::back_inserter(*benchmarks));
- } else if (family->rangeY_.empty()) {
- for (size_t x = 0; x < family->rangeX_.size(); ++x) {
- instances = family->CreateBenchmarkInstances(
- x, Benchmark::kNoRangeIndex);
- std::copy(instances.begin(), instances.end(),
- std::back_inserter(*benchmarks));
- }
- } 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);
- std::copy(instances.begin(), instances.end(),
- std::back_inserter(*benchmarks));
- }
- }
- }
- }
-}
-
-std::string ConsoleReporter::PrintMemoryUsage(double bytes) const {
- 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 {
- name_field_width_ = context.name_field_width;
-
- std::cout << "Benchmarking on " << context.num_cpus << " X "
- << context.mhz_per_cpu << " MHz CPU"
- << ((context.num_cpus > 1) ? "s" : "") << "\n";
-
- int remainder_ms;
- std::cout << walltime::Print(walltime::Now(), "%Y/%m/%d-%H:%M:%S",
- true, // use local timezone
- &remainder_ms) << "\n";
-
- // Show details of CPU model, caches, TLBs etc.
- // if (!context.cpu_info.empty())
- // std::cout << "CPU: " << context.cpu_info.c_str();
-
- if (context.cpu_scaling_enabled) {
- std::cerr << "CPU scaling is enabled: Benchmark timings may be noisy.\n";
- }
-
- int output_width = fprintf(stdout, "%s%-*s %10s %10s %10s\n",
- Prefix(), int(name_field_width_), "Benchmark",
- "Time(ns)", "CPU(ns)", "Iterations");
- std::cout << std::string(output_width - 1, '-').c_str() << "\n";
-
- return true;
-}
-
-void ConsoleReporter::ReportRuns(
- const std::vector<BenchmarkReporter::Run>& reports) const {
- for (std::vector<BenchmarkReporter::Run>::const_iterator it = reports.begin();
- it != reports.end(); ++it) {
- CHECK_EQ(reports[0].benchmark_name, it->benchmark_name);
- PrintRunData(*it);
- }
-
- // We don't report aggregated data if there was a single run.
- if (reports.size() < 2) return;
-
- BenchmarkReporter::Run mean_data;
- BenchmarkReporter::Run stddev_data;
- ComputeStats(reports, &mean_data, &stddev_data);
-
- PrintRunData(mean_data);
- PrintRunData(stddev_data);
-}
-
-void ConsoleReporter::PrintRunData(const BenchmarkReporter::Run& result) const {
- // Format bytes per second
- std::string rate;
- if (result.bytes_per_second > 0) {
- std::stringstream ss;
- ss << " " << HumanReadableNumber(result.bytes_per_second) << "B/s";
- rate = ss.str();
- }
-
- // Format items per second
- std::string items;
- if (result.items_per_second > 0) {
- std::stringstream ss;
- ss << " " << HumanReadableNumber(result.items_per_second) << " items/s";
- items = ss.str();
- }
-
- ColorPrintf(COLOR_DEFAULT, "%s", Prefix());
- ColorPrintf(COLOR_GREEN, "%-*s ",
- name_field_width_, result.benchmark_name.c_str());
- if (result.iterations == 0) {
- ColorPrintf(COLOR_YELLOW, "%10.0f %10.0f ",
- result.real_accumulated_time * 1e9,
- result.cpu_accumulated_time * 1e9);
- } else {
- ColorPrintf(COLOR_YELLOW, "%10.0f %10.0f ",
- (result.real_accumulated_time * 1e9) /
- (static_cast<double>(result.iterations)),
- (result.cpu_accumulated_time * 1e9) /
- (static_cast<double>(result.iterations)));
- }
- ColorPrintf(COLOR_CYAN, "%10lld", result.iterations);
- ColorPrintf(COLOR_DEFAULT, "%*s %*s %s %s\n",
- 13, rate.c_str(),
- 18, items.c_str(),
- result.report_label.c_str(),
- PrintMemoryUsage(result.max_heapbytes_used).c_str());
-}
-
-/* TODO(dominic)
-void MemoryUsage() {
- // if (benchmark_mc) {
- // benchmark_mc->Reset();
- //} else {
- get_memory_usage = true;
- //}
-}
-*/
-
-void PrintUsageAndExit() {
- fprintf(stdout,
- "benchmark [--benchmark_filter=<regex>]\n"
- " [--benchmark_iterations=<iterations>]\n"
- " [--benchmark_min_time=<min_time>]\n"
- //" [--benchmark_memory_usage]\n"
- " [--benchmark_repetitions=<num_repetitions>]\n"
- " [--color_print={true|false}]\n"
- " [--v=<verbosity>]\n");
- exit(0);
-}
-
-void ParseCommandLineFlags(int* argc, const char** argv) {
- for (int i = 1; i < *argc; ++i) {
- if (ParseStringFlag(argv[i], "benchmark_filter", &FLAGS_benchmark_filter) ||
- ParseInt32Flag(argv[i], "benchmark_iterations",
- &FLAGS_benchmark_iterations) ||
- ParseDoubleFlag(argv[i], "benchmark_min_time",
- &FLAGS_benchmark_min_time) ||
- // TODO(dominic)
- // ParseBoolFlag(argv[i], "gbenchmark_memory_usage",
- // &FLAGS_gbenchmark_memory_usage) ||
- ParseInt32Flag(argv[i], "benchmark_repetitions",
- &FLAGS_benchmark_repetitions) ||
- ParseBoolFlag(argv[i], "color_print", &FLAGS_color_print) ||
- ParseInt32Flag(argv[i], "v", &FLAGS_v)) {
- for (int j = i; j != *argc; ++j) argv[j] = argv[j + 1];
-
- --(*argc);
- --i;
- } else if (IsFlag(argv[i], "help"))
- PrintUsageAndExit();
- }
-}
-
-} // end namespace internal
-
-// A clock that provides a fast mechanism to check if we're nearly done.
-class State::FastClock {
- public:
- enum Type {
- REAL_TIME,
- CPU_TIME
- };
- explicit FastClock(Type type)
- : type_(type),
- approx_time_(NowMicros()),
- bg_done_(false),
- bg_(BGThreadWrapper, this) { }
-
- ~FastClock() {
- {
- std::unique_lock<std::mutex> l(bg_mutex_);
- bg_done_ = true;
- bg_cond_.notify_one();
- }
- bg_.join();
- }
-
- // Returns true if the current time is guaranteed to be past "when_micros".
- // This method is very fast.
- inline bool HasReached(int64_t when_micros) {
- return std::atomic_load(&approx_time_) >= when_micros;
- }
-
- // Returns the current time in microseconds past the epoch.
- int64_t NowMicros() const {
- double t = 0;
- switch (type_) {
- case REAL_TIME:
- t = walltime::Now();
- break;
- case CPU_TIME:
- t = MyCPUUsage() + ChildrenCPUUsage();
- break;
- }
- return static_cast<int64_t>(t * kNumMicrosPerSecond);
- }
-
- // Reinitialize if necessary (since clock type may be change once benchmark
- // function starts running - see UseRealTime).
- void InitType(Type type) {
- type_ = type;
- std::lock_guard<std::mutex> l(bg_mutex_);
- std::atomic_store(&approx_time_, NowMicros());
- }
-
- private:
- Type type_;
- std::atomic<int64_t> approx_time_; // Last time measurement taken by bg_
- bool bg_done_; // This is used to signal background thread to exit
- std::mutex bg_mutex_;
- std::condition_variable bg_cond_;
- std::thread bg_; // Background thread that updates last_time_ once every ms
-
- static void* BGThreadWrapper(void* that) {
- ((FastClock*)that)->BGThread();
- return NULL;
- }
-
- void BGThread() {
- std::unique_lock<std::mutex> l(bg_mutex_);
- while (!bg_done_)
- {
- // Set timeout to 1 ms.
- bg_cond_.wait_for(l, std::chrono::milliseconds(1));
- std::atomic_store(&approx_time_, NowMicros());
- }
- }
-
- BENCHMARK_DISALLOW_COPY_AND_ASSIGN(FastClock);
-};
-
-struct State::ThreadStats {
- int64_t bytes_processed;
- int64_t items_processed;
-
- ThreadStats() { Reset(); }
-
- void Reset() {
- bytes_processed = 0;
- items_processed = 0;
- }
-
- void Add(const ThreadStats& other) {
- bytes_processed += other.bytes_processed;
- items_processed += other.items_processed;
- }
-};
-
-namespace internal {
-
-// Information kept per benchmark we may want to run
-struct Benchmark::Instance {
- Instance()
- : bm(nullptr),
- threads(1),
- rangeXset(false),
- rangeX(kNoRange),
- rangeYset(false),
- rangeY(kNoRange) {}
-
- std::string name;
- Benchmark* bm;
- int threads; // Number of concurrent threads to use
-
- bool rangeXset;
- int rangeX;
- bool rangeYset;
- int rangeY;
-
- bool multithreaded() const { return !bm->thread_counts_.empty(); }
-};
-
-} // end namespace internal
-
-struct State::SharedState {
- const internal::Benchmark::Instance* instance;
- std::mutex mu;
- std::condition_variable cond;
- int starting; // Number of threads that have entered STARTING state
- int stopping; // Number of threads that have entered STOPPING state
- int exited; // Number of threads that have complete exited
- int threads; // Number of total threads that are running concurrently
- ThreadStats stats;
- std::vector<BenchmarkReporter::Run> runs; // accumulated runs
- std::string label;
-
- explicit SharedState(const internal::Benchmark::Instance* b)
- : instance(b),
- starting(0),
- stopping(0),
- exited(0),
- threads(b == nullptr ? 1 : b->threads) { }
-
- BENCHMARK_DISALLOW_COPY_AND_ASSIGN(SharedState);
-};
-
-namespace internal {
-
-Benchmark::Benchmark(const char* name, BenchmarkFunction f)
- : name_(name), function_(f) {
- registration_index_ = BenchmarkFamilies::GetInstance()->AddBenchmark(this);
-}
-
-Benchmark::~Benchmark() {
- BenchmarkFamilies::GetInstance()->RemoveBenchmark(registration_index_);
-}
-
-Benchmark* Benchmark::Arg(int x) {
- std::lock_guard<std::mutex> l(mutex_);
- rangeX_.push_back(x);
- return this;
-}
-
-Benchmark* Benchmark::Range(int start, int limit) {
- std::vector<int> arglist;
- AddRange(&arglist, start, limit, kRangeMultiplier);
-
- std::lock_guard<std::mutex> l(mutex_);
- for (size_t i = 0; i < arglist.size(); ++i) rangeX_.push_back(arglist[i]);
- return this;
-}
-
-Benchmark* Benchmark::DenseRange(int start, int limit) {
- CHECK_GE(start, 0);
- CHECK_LE(start, limit);
- std::lock_guard<std::mutex> l(mutex_);
- for (int arg = start; arg <= limit; ++arg) rangeX_.push_back(arg);
- return this;
-}
-
-Benchmark* Benchmark::ArgPair(int x, int y) {
- std::lock_guard<std::mutex> l(mutex_);
- rangeX_.push_back(x);
- rangeY_.push_back(y);
- return this;
-}
-
-Benchmark* Benchmark::RangePair(int lo1, int hi1, int lo2, int hi2) {
- std::vector<int> arglist1, arglist2;
- AddRange(&arglist1, lo1, hi1, kRangeMultiplier);
- AddRange(&arglist2, lo2, hi2, kRangeMultiplier);
-
- std::lock_guard<std::mutex> l(mutex_);
- rangeX_.resize(arglist1.size());
- std::copy(arglist1.begin(), arglist1.end(), rangeX_.begin());
- rangeY_.resize(arglist2.size());
- std::copy(arglist2.begin(), arglist2.end(), rangeY_.begin());
- return this;
-}
-
-Benchmark* Benchmark::Apply(void (*custom_arguments)(Benchmark* benchmark)) {
- custom_arguments(this);
- return this;
-}
-
-Benchmark* Benchmark::Threads(int t) {
- CHECK_GT(t, 0);
- std::lock_guard<std::mutex> l(mutex_);
- thread_counts_.push_back(t);
- return this;
-}
-
-Benchmark* Benchmark::ThreadRange(int min_threads, int max_threads) {
- CHECK_GT(min_threads, 0);
- CHECK_GE(max_threads, min_threads);
-
- std::lock_guard<std::mutex> l(mutex_);
- AddRange(&thread_counts_, min_threads, max_threads, 2);
- return this;
-}
-
-Benchmark* Benchmark::ThreadPerCpu() {
- std::lock_guard<std::mutex> l(mutex_);
- thread_counts_.push_back(NumCPUs());
- return this;
-}
-
-void Benchmark::AddRange(std::vector<int>* dst, int lo, int hi, int mult) {
- CHECK_GE(lo, 0);
- CHECK_GE(hi, lo);
-
- // Add "lo"
- dst->push_back(lo);
-
- // Now space out the benchmarks in multiples of "mult"
- for (int32_t i = 1; i < std::numeric_limits<int32_t>::max() / mult;
- i *= mult) {
- if (i >= hi) break;
- if (i > lo) dst->push_back(i);
- }
- // Add "hi" (if different from "lo")
- if (hi != lo) dst->push_back(hi);
-}
-
-std::vector<Benchmark::Instance> Benchmark::CreateBenchmarkInstances(
- size_t rangeXindex, size_t rangeYindex) {
- // Special list of thread counts to use when none are specified
- std::vector<int> one_thread;
- one_thread.push_back(1);
-
- std::vector<Benchmark::Instance> instances;
-
- const bool is_multithreaded = (!thread_counts_.empty());
- const std::vector<int>& thread_counts =
- (is_multithreaded ? thread_counts_ : one_thread);
- for (int num_threads : thread_counts) {
- Instance instance;
- instance.name = name_;
- instance.bm = this;
- instance.threads = num_threads;
-
- if (rangeXindex != kNoRangeIndex) {
- instance.rangeX = rangeX_[rangeXindex];
- instance.rangeXset = true;
- AppendHumanReadable(instance.rangeX, &instance.name);
- }
- if (rangeYindex != kNoRangeIndex) {
- instance.rangeY = rangeY_[rangeYindex];
- instance.rangeYset = true;
- AppendHumanReadable(instance.rangeY, &instance.name);
- }
-
- // Add the number of threads used to the name
- if (is_multithreaded) {
- std::stringstream ss;
- ss << "/threads:" << instance.threads;
- instance.name += ss.str();
- }
-
- instances.push_back(instance);
- }
-
- return instances;
-}
-
-void Benchmark::MeasureOverhead() {
- State::FastClock clock(State::FastClock::CPU_TIME);
- State::SharedState state(nullptr);
- State runner(&clock, &state, 0);
- while (runner.KeepRunning()) {
- }
- overhead = state.runs[0].real_accumulated_time /
- static_cast<double>(state.runs[0].iterations);
- VLOG(1) << "Per-iteration overhead for doing nothing: " << overhead << "\n";
-}
-
-void Benchmark::RunInstance(const Instance& b, const BenchmarkReporter* br) {
- use_real_time = false;
- running_benchmark = true;
- // get_memory_usage = FLAGS_gbenchmark_memory_usage;
- State::FastClock clock(State::FastClock::CPU_TIME);
-
- // Initialize the test runners.
- State::SharedState state(&b);
- {
- std::vector<std::unique_ptr<State>> runners;
- for (int i = 0; i < b.threads; ++i)
- runners.push_back(std::unique_ptr<State>(new State(&clock, &state, i)));
-
- // Run them all.
- for (int i = 0; i < b.threads; ++i) {
- if (b.multithreaded())
- runners[i]->RunAsThread();
- else
- runners[i]->Run();
- }
- if (b.multithreaded()) {
- for (int i = 0; i < b.threads; ++i) runners[i]->Wait();
- }
- }
- /*
- double mem_usage = 0;
- if (get_memory_usage) {
- // Measure memory usage
- Notification mem_done;
- BenchmarkRun mem_run;
- BenchmarkRun::SharedState mem_shared(&b, 1);
- mem_run.Init(&clock, &mem_shared, 0);
- {
- testing::MallocCounter mc(testing::MallocCounter::THIS_THREAD_ONLY);
- benchmark_mc = &mc;
- mem_run.Run(&mem_done);
- mem_done.WaitForNotification();
- benchmark_mc = NULL;
- mem_usage = mc.PeakHeapGrowth();
- }
- }
- */
- running_benchmark = false;
-
- for (BenchmarkReporter::Run& report : state.runs) {
- double seconds = (use_real_time ? report.real_accumulated_time
- : report.cpu_accumulated_time);
- report.benchmark_name = b.name;
- report.report_label = state.label;
- report.bytes_per_second = state.stats.bytes_processed / seconds;
- report.items_per_second = state.stats.items_processed / seconds;
- report.max_heapbytes_used = MeasurePeakHeapMemory(b);
- }
-
- br->ReportRuns(state.runs);
-}
-
-// Run the specified benchmark, measure its peak memory usage, and
-// return the peak memory usage.
-double Benchmark::MeasurePeakHeapMemory(const Instance&) {
- if (!get_memory_usage) return 0.0;
- double bytes = 0.0;
- /* TODO(dominich)
- // Should we do multi-threaded runs?
- const int num_threads = 1;
- const int num_iters = 1;
- {
- // internal::MallocCounter mc(internal::MallocCounter::THIS_THREAD_ONLY);
- running_benchmark = true;
- timer_manager = new TimerManager(1, NULL);
- // benchmark_mc = &mc;
- timer_manager->StartTimer();
-
- b.Run(num_iters);
-
- running_benchmark = false;
- delete timer_manager;
- timer_manager = NULL;
- // benchmark_mc = NULL;
- // bytes = mc.PeakHeapGrowth();
- }
- */
- return bytes;
-}
-
-} // end namespace internal
-
-State::State(FastClock* clock, SharedState* s, int t)
- : thread_index(t),
- state_(STATE_INITIAL),
- clock_(clock),
- shared_(s),
- iterations_(0),
- start_cpu_(0.0),
- start_time_(0.0),
- stop_time_micros_(0.0),
- start_pause_cpu_(0.0),
- pause_cpu_time_(0.0),
- start_pause_real_(0.0),
- pause_real_time_(0.0),
- total_iterations_(0),
- interval_micros_(static_cast<int64_t>(kNumMicrosPerSecond *
- FLAGS_benchmark_min_time /
- FLAGS_benchmark_repetitions)),
- is_continuation_(false),
- stats_(new ThreadStats()) {
- CHECK(clock != nullptr);
- CHECK(s != nullptr);
-}
-
-bool State::KeepRunning() {
- // Fast path
- if ((FLAGS_benchmark_iterations == 0 &&
- !clock_->HasReached(stop_time_micros_ +
- kNumMicrosPerSecond * pause_real_time_)) ||
- iterations_ < FLAGS_benchmark_iterations) {
- ++iterations_;
- return true;
- }
-
- // To block thread 0 until all other threads exit, we have a signal exit
- // point for KeepRunning() to return false. The fast path above always
- // returns true.
- bool ret = false;
- switch (state_) {
- case STATE_INITIAL:
- ret = StartRunning();
- break;
- case STATE_STARTING:
- CHECK(false);
- ret = true;
- break;
- case STATE_RUNNING:
- ret = FinishInterval();
- break;
- case STATE_STOPPING:
- ret = MaybeStop();
- break;
- case STATE_STOPPED:
- CHECK(false);
- ret = true;
- break;
- }
-
- if (!ret && shared_->threads > 1 && thread_index == 0){
- std::unique_lock<std::mutex> l(shared_->mu);
-
- // Block until all other threads have exited. We can then safely cleanup
- // without other threads continuing to access shared variables inside the
- // user-provided run function.
- while (shared_->exited < shared_->threads - 1) {
- shared_->cond.wait(l);
- }
- }
-
- if (ret) {
- ++iterations_;
- }
- return ret;
-}
-
-void State::PauseTiming() {
- start_pause_cpu_ = MyCPUUsage() + ChildrenCPUUsage();
- start_pause_real_ = walltime::Now();
-}
-
-void State::ResumeTiming() {
- pause_cpu_time_ += MyCPUUsage() + ChildrenCPUUsage() - start_pause_cpu_;
- pause_real_time_ += walltime::Now() - start_pause_real_;
-}
-
-void State::SetBytesProcessed(int64_t bytes) {
- CHECK_EQ(STATE_STOPPED, state_);
- std::lock_guard<std::mutex> l(shared_->mu);
- stats_->bytes_processed = bytes;
-}
-
-void State::SetItemsProcessed(int64_t items) {
- CHECK_EQ(STATE_STOPPED, state_);
- std::lock_guard<std::mutex> l(shared_->mu);
- stats_->items_processed = items;
-}
-
-void State::SetLabel(const std::string& label) {
- CHECK_EQ(STATE_STOPPED, state_);
- std::lock_guard<std::mutex> l(shared_->mu);
- shared_->label = label;
-}
-
-int State::range_x() const {
- CHECK(shared_->instance->rangeXset);
- /*
- <<
- "Failed to get range_x as it was not set. Did you register your "
- "benchmark with a range parameter?";
- */
- return shared_->instance->rangeX;
-}
-
-int State::range_y() const {
- CHECK(shared_->instance->rangeYset);
- /* <<
- "Failed to get range_y as it was not set. Did you register your "
- "benchmark with a range parameter?";
- */
- return shared_->instance->rangeY;
-}
-
-bool State::StartRunning() {
- bool last_thread = false;
- {
- std::lock_guard<std::mutex> l(shared_->mu);
- CHECK_EQ(state_, STATE_INITIAL);
- state_ = STATE_STARTING;
- is_continuation_ = false;
- CHECK_LT(shared_->starting, shared_->threads);
- ++shared_->starting;
- last_thread = shared_->starting == shared_->threads;
- }
-
- if (last_thread) {
- clock_->InitType(use_real_time ? FastClock::REAL_TIME
- : FastClock::CPU_TIME);
- {
- std::lock_guard<std::mutex> l(starting_mutex);
- starting_cv.notify_all();
- }
- } else {
- std::unique_lock<std::mutex> l(starting_mutex);
- starting_cv.wait(l);
- }
- CHECK_EQ(state_, STATE_STARTING);
- state_ = STATE_RUNNING;
-
- NewInterval();
- return true;
-}
-
-void State::NewInterval() {
- stop_time_micros_ = clock_->NowMicros() + interval_micros_;
- if (!is_continuation_) {
- VLOG(1) << "Starting new interval; stopping in " << interval_micros_
- << "\n";
- iterations_ = 0;
- pause_cpu_time_ = 0;
- pause_real_time_ = 0;
- start_cpu_ = MyCPUUsage() + ChildrenCPUUsage();
- start_time_ = walltime::Now();
- } else {
- VLOG(1) << "Continuing interval; stopping in " << interval_micros_
- << "\n";
- }
-}
-
-bool State::FinishInterval() {
- if ((FLAGS_benchmark_iterations != 0 &&
- iterations_ <
- FLAGS_benchmark_iterations / FLAGS_benchmark_repetitions) ||
- iterations_ < 1) {
- interval_micros_ *= 2;
- VLOG(1) << "Not enough iterations in interval; "
- << "Trying again for " << interval_micros_ << " useconds.\n";
- is_continuation_ = false;
- NewInterval();
- return true;
- }
-
- BenchmarkReporter::Run data;
- data.iterations = iterations_;
- data.thread_index = thread_index;
-
- const double accumulated_time = walltime::Now() - start_time_;
- const double total_overhead = overhead * iterations_;
- CHECK_LT(pause_real_time_, accumulated_time);
- CHECK_LT(pause_real_time_ + total_overhead, accumulated_time);
- data.real_accumulated_time =
- accumulated_time - (pause_real_time_ + total_overhead);
- data.cpu_accumulated_time = (MyCPUUsage() + ChildrenCPUUsage()) -
- (pause_cpu_time_ + start_cpu_);
- total_iterations_ += iterations_;
-
- bool keep_going = false;
- {
- std::lock_guard<std::mutex> l(shared_->mu);
-
- // Either replace the last or add a new data point.
- if (is_continuation_)
- shared_->runs.back() = data;
- else
- shared_->runs.push_back(data);
-
- if (FLAGS_benchmark_iterations != 0) {
- // If we need more iterations, run another interval as a continuation.
- keep_going = total_iterations_ < FLAGS_benchmark_iterations;
- is_continuation_ = keep_going;
- } else {
- // If this is a repetition, run another interval as a new data point.
- keep_going = shared_->runs.size() <
- static_cast<size_t>(FLAGS_benchmark_repetitions);
- is_continuation_ = !keep_going;
- }
-
- if (!keep_going) {
- ++shared_->stopping;
- if (shared_->stopping < shared_->threads) {
- // Other threads are still running, so continue running but without
- // timing to present an expected background load to the other threads.
- state_ = STATE_STOPPING;
- keep_going = true;
- } else {
- state_ = STATE_STOPPED;
- }
- }
- }
-
- if (state_ == STATE_RUNNING) NewInterval();
- return keep_going;
-}
-
-bool State::MaybeStop() {
- std::lock_guard<std::mutex> l(shared_->mu);
- if (shared_->stopping < shared_->threads) {
- CHECK_EQ(state_, STATE_STOPPING);
- return true;
- }
- state_ = STATE_STOPPED;
- return false;
-}
-
-void State::Run() {
- stats_->Reset();
- shared_->instance->bm->function_(*this);
- {
- std::lock_guard<std::mutex> l(shared_->mu);
- shared_->stats.Add(*stats_);
- }
-}
-
-void State::RunAsThread() {
- thread_ = std::thread(State::RunWrapper, this);
-}
-
-void State::Wait() {
- if (thread_.joinable()) {
- thread_.join();
- }
-}
-
-// static
-void* State::RunWrapper(void* arg) {
- State* that = (State*)arg;
- CHECK(that != nullptr);
- that->Run();
-
- std::lock_guard<std::mutex> l(that->shared_->mu);
-
- that->shared_->exited++;
- if (that->thread_index > 0 &&
- that->shared_->exited == that->shared_->threads - 1) {
- // All threads but thread 0 have exited the user-provided run function.
- // Thread 0 can now wake up and exit.
- that->shared_->cond.notify_one();
- }
-
- return nullptr;
-}
-
-namespace internal {
-
-void RunMatchingBenchmarks(const std::string& spec,
- const BenchmarkReporter* reporter) {
- if (spec.empty()) return;
-
- std::vector<internal::Benchmark::Instance> benchmarks;
- BenchmarkFamilies::GetInstance()->FindBenchmarks(spec, &benchmarks);
-
- // Determine the width of the name field using a minimum width of 10.
- // Also determine max number of threads needed.
- size_t name_field_width = 10;
- for (const internal::Benchmark::Instance& benchmark : benchmarks) {
- // Add width for _stddev and threads:XX
- if (benchmark.threads > 1 && FLAGS_benchmark_repetitions > 1) {
- name_field_width =
- std::max<size_t>(name_field_width, benchmark.name.size() + 17);
- } else if (benchmark.threads > 1) {
- name_field_width =
- std::max<size_t>(name_field_width, benchmark.name.size() + 10);
- } else if (FLAGS_benchmark_repetitions > 1) {
- name_field_width =
- std::max<size_t>(name_field_width, benchmark.name.size() + 7);
- } else {
- name_field_width =
- std::max<size_t>(name_field_width, benchmark.name.size());
- }
- }
-
- // Print header here
- BenchmarkReporter::Context context;
- context.num_cpus = NumCPUs();
- context.mhz_per_cpu = CyclesPerSecond() / 1000000.0f;
- // context.cpu_info = base::CompactCPUIDInfoString();
- context.cpu_scaling_enabled = CpuScalingEnabled();
- context.name_field_width = name_field_width;
-
- if (reporter->ReportContext(context))
- for (internal::Benchmark::Instance& benchmark : benchmarks)
- Benchmark::RunInstance(benchmark, reporter);
-}
-
-void FindMatchingBenchmarkNames(const std::string& spec,
- std::vector<std::string>* benchmark_names) {
- if (spec.empty()) return;
-
- std::vector<internal::Benchmark::Instance> benchmarks;
- BenchmarkFamilies::GetInstance()->FindBenchmarks(spec, &benchmarks);
- std::transform(benchmarks.begin(), benchmarks.end(), benchmark_names->begin(),
- [](const internal::Benchmark::Instance& b) { return b.name; });
-}
-
-} // end namespace internal
-
-void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter /*= nullptr*/) {
- std::string spec = FLAGS_benchmark_filter;
- if (spec.empty() || spec == "all")
- spec = "."; // Regexp that matches all benchmarks
- internal::ConsoleReporter default_reporter;
- internal::RunMatchingBenchmarks(
- spec, reporter == nullptr ? &default_reporter : reporter);
-}
-
-void UseRealTime() { use_real_time = true; }
-
-void Initialize(int* argc, const char** argv) {
- internal::ParseCommandLineFlags(argc, argv);
- internal::SetLogLevel(FLAGS_v);
- // Ensure walltime is initialized by a single thread by forcing the
- // initialization.
- walltime::Now();
- internal::Benchmark::MeasureOverhead();
-}
-
-} // end namespace benchmark
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/check.h
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/check.h b/third_party/benchmark/src/check.h
deleted file mode 100644
index 2b04cd2..0000000
--- a/third_party/benchmark/src/check.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef CHECK_H_
-#define CHECK_H_
-
-#include <cstdlib>
-#include <ostream>
-
-#include "internal_macros.h"
-#include "log.h"
-
-namespace benchmark {
-namespace internal {
-
-// CheckHandler is the class constructed by failing CHECK macros. CheckHandler
-// will log information about the failures and abort when it is destructed.
-class CheckHandler {
-public:
- CheckHandler(const char* check, const char* file, const char* func, int line)
- : log_(GetErrorLogInstance())
- {
- log_ << file << ":" << line << ": " << func << ": Check `"
- << check << "' failed. ";
- }
-
- std::ostream& GetLog() {
- return log_;
- }
-
- BENCHMARK_NORETURN ~CheckHandler() {
- log_ << std::endl;
- std::abort();
- }
-
-private:
- std::ostream& log_;
-};
-
-} // end namespace internal
-} // end namespace benchmark
-
-// The CHECK macro returns a std::ostream object that can have extra information
-// written to it.
-#ifndef NDEBUG
-# define CHECK(b) (b ? ::benchmark::internal::GetNullLogInstance() \
- : ::benchmark::internal::CheckHandler( \
- #b, __FILE__, __func__, __LINE__).GetLog())
-#else
-# define CHECK(b) ::benchmark::internal::GetNullLogInstance()
-#endif
-
-#define CHECK_EQ(a, b) CHECK((a) == (b))
-#define CHECK_NE(a, b) CHECK((a) != (b))
-#define CHECK_GE(a, b) CHECK((a) >= (b))
-#define CHECK_LE(a, b) CHECK((a) <= (b))
-#define CHECK_GT(a, b) CHECK((a) > (b))
-#define CHECK_LT(a, b) CHECK((a) < (b))
-
-#endif // CHECK_H_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/colorprint.cc
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/colorprint.cc b/third_party/benchmark/src/colorprint.cc
deleted file mode 100644
index 783797b..0000000
--- a/third_party/benchmark/src/colorprint.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2015 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.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "colorprint.h"
-
-#include <cstdarg>
-
-#include "commandlineflags.h"
-#include "internal_macros.h"
-
-DECLARE_bool(color_print);
-
-namespace benchmark {
-namespace {
-#ifdef OS_WINDOWS
-typedef WORD PlatformColorCode;
-#else
-typedef const char* PlatformColorCode;
-#endif
-
-PlatformColorCode GetPlatformColorCode(LogColor color) {
-#ifdef OS_WINDOWS
- switch (color) {
- case COLOR_RED:
- return FOREGROUND_RED;
- case COLOR_GREEN:
- return FOREGROUND_GREEN;
- case COLOR_YELLOW:
- return FOREGROUND_RED | FOREGROUND_GREEN;
- case COLOR_BLUE:
- return FOREGROUND_BLUE;
- case COLOR_MAGENTA:
- return FOREGROUND_BLUE | FOREGROUND_RED;
- case COLOR_CYAN:
- return FOREGROUND_BLUE | FOREGROUND_GREEN;
- case COLOR_WHITE: // fall through to default
- default:
- return 0;
- }
-#else
- switch (color) {
- case COLOR_RED:
- return "1";
- case COLOR_GREEN:
- return "2";
- case COLOR_YELLOW:
- return "3";
- case COLOR_BLUE:
- return "4";
- case COLOR_MAGENTA:
- return "5";
- case COLOR_CYAN:
- return "6";
- case COLOR_WHITE:
- return "7";
- default:
- return NULL;
- };
-#endif
-}
-} // end namespace
-
-void ColorPrintf(LogColor color, const char* fmt, ...) {
- va_list args;
- va_start(args, fmt);
-
- if (!FLAGS_color_print) {
- vprintf(fmt, args);
- va_end(args);
- return;
- }
-
-#ifdef OS_WINDOWS
- const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
-
- // Gets the current text color.
- CONSOLE_SCREEN_BUFFER_INFO buffer_info;
- GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
- const WORD old_color_attrs = buffer_info.wAttributes;
-
- // We need to flush the stream buffers into the console before each
- // SetConsoleTextAttribute call lest it affect the text that is already
- // printed but has not yet reached the console.
- fflush(stdout);
- SetConsoleTextAttribute(stdout_handle,
- GetPlatformColorCode(color) | FOREGROUND_INTENSITY);
- vprintf(fmt, args);
-
- fflush(stdout);
- // Restores the text color.
- SetConsoleTextAttribute(stdout_handle, old_color_attrs);
-#else
- const char* color_code = GetPlatformColorCode(color);
- if (color_code) fprintf(stdout, "\033[0;3%sm", color_code);
- vprintf(fmt, args);
- printf("\033[m"); // Resets the terminal to default.
-#endif
- va_end(args);
-}
-} // end namespace benchmark
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/colorprint.h
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/colorprint.h b/third_party/benchmark/src/colorprint.h
deleted file mode 100644
index 54d1f66..0000000
--- a/third_party/benchmark/src/colorprint.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef BENCHMARK_COLORPRINT_H_
-#define BENCHMARK_COLORPRINT_H_
-
-namespace benchmark {
-enum LogColor {
- COLOR_DEFAULT,
- COLOR_RED,
- COLOR_GREEN,
- COLOR_YELLOW,
- COLOR_BLUE,
- COLOR_MAGENTA,
- COLOR_CYAN,
- COLOR_WHITE
-};
-
-void ColorPrintf(LogColor color, const char* fmt, ...);
-} // end namespace benchmark
-
-#endif // BENCHMARK_COLORPRINT_H_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/commandlineflags.cc
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/commandlineflags.cc b/third_party/benchmark/src/commandlineflags.cc
deleted file mode 100644
index 06246e9..0000000
--- a/third_party/benchmark/src/commandlineflags.cc
+++ /dev/null
@@ -1,220 +0,0 @@
-// Copyright 2015 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.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "commandlineflags.h"
-
-#include <cstdlib>
-#include <cstring>
-#include <iostream>
-#include <limits>
-
-namespace benchmark {
-// Parses 'str' for a 32-bit signed integer. If successful, writes
-// the result to *value and returns true; otherwise leaves *value
-// unchanged and returns false.
-bool ParseInt32(const std::string& src_text, const char* str, int32_t* value) {
- // Parses the environment variable as a decimal integer.
- char* end = NULL;
- const long long_value = strtol(str, &end, 10); // NOLINT
-
- // Has strtol() consumed all characters in the string?
- if (*end != '\0') {
- // No - an invalid character was encountered.
- std::cerr << src_text << " is expected to be a 32-bit integer, "
- << "but actually has value \"" << str << "\".\n";
- return false;
- }
-
- // Is the parsed value in the range of an Int32?
- const int32_t result = static_cast<int32_t>(long_value);
- if (long_value == std::numeric_limits<long>::max() ||
- long_value == std::numeric_limits<long>::min() ||
- // The parsed value overflows as a long. (strtol() returns
- // LONG_MAX or LONG_MIN when the input overflows.)
- result != long_value
- // The parsed value overflows as an Int32.
- ) {
- std::cerr << src_text << " is expected to be a 32-bit integer, "
- << "but actually has value \"" << str << "\", "
- << "which overflows.\n";
- return false;
- }
-
- *value = result;
- return true;
-}
-
-// Parses 'str' for a double. If successful, writes the result to *value and
-// returns true; otherwise leaves *value unchanged and returns false.
-bool ParseDouble(const std::string& src_text, const char* str, double* value) {
- // Parses the environment variable as a decimal integer.
- char* end = NULL;
- const double double_value = strtod(str, &end); // NOLINT
-
- // Has strtol() consumed all characters in the string?
- if (*end != '\0') {
- // No - an invalid character was encountered.
- std::cerr << src_text << " is expected to be a double, "
- << "but actually has value \"" << str << "\".\n";
- return false;
- }
-
- *value = double_value;
- return true;
-}
-
-inline const char* GetEnv(const char* name) {
-#if defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
- // Environment variables which we programmatically clear will be set to the
- // empty string rather than unset (NULL). Handle that case.
- const char* const env = getenv(name);
- return (env != NULL && env[0] != '\0') ? env : NULL;
-#else
- return getenv(name);
-#endif
-}
-
-// Returns the name of the environment variable corresponding to the
-// given flag. For example, FlagToEnvVar("foo") will return
-// "BENCHMARK_FOO" in the open-source version.
-static std::string FlagToEnvVar(const char* flag) {
- const std::string flag_str(flag);
-
- std::string env_var;
- for (size_t i = 0; i != flag_str.length(); ++i)
- env_var += ::toupper(flag_str.c_str()[i]);
-
- return "BENCHMARK_" + env_var;
-}
-
-// Reads and returns the Boolean environment variable corresponding to
-// the given flag; if it's not set, returns default_value.
-//
-// The value is considered true iff it's not "0".
-bool BoolFromEnv(const char* flag, bool default_value) {
- const std::string env_var = FlagToEnvVar(flag);
- const char* const string_value = GetEnv(env_var.c_str());
- return string_value == NULL ? default_value : strcmp(string_value, "0") != 0;
-}
-
-// Reads and returns a 32-bit integer stored in the environment
-// variable corresponding to the given flag; if it isn't set or
-// doesn't represent a valid 32-bit integer, returns default_value.
-int32_t Int32FromEnv(const char* flag, int32_t default_value) {
- const std::string env_var = FlagToEnvVar(flag);
- const char* const string_value = GetEnv(env_var.c_str());
- if (string_value == NULL) {
- // The environment variable is not set.
- return default_value;
- }
-
- int32_t result = default_value;
- if (!ParseInt32(std::string("Environment variable ") + env_var, string_value,
- &result)) {
- std::cout << "The default value " << default_value << " is used.\n";
- return default_value;
- }
-
- return result;
-}
-
-// Reads and returns the string environment variable corresponding to
-// the given flag; if it's not set, returns default_value.
-const char* StringFromEnv(const char* flag, const char* default_value) {
- const std::string env_var = FlagToEnvVar(flag);
- const char* const value = GetEnv(env_var.c_str());
- return value == NULL ? default_value : value;
-}
-
-// Parses a string as a command line flag. The string should have
-// the format "--flag=value". When def_optional is true, the "=value"
-// part can be omitted.
-//
-// Returns the value of the flag, or NULL if the parsing failed.
-const char* ParseFlagValue(const char* str, const char* flag,
- bool def_optional) {
- // str and flag must not be NULL.
- if (str == NULL || flag == NULL) return NULL;
-
- // The flag must start with "--".
- const std::string flag_str = std::string("--") + std::string(flag);
- const size_t flag_len = flag_str.length();
- if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;
-
- // Skips the flag name.
- const char* flag_end = str + flag_len;
-
- // When def_optional is true, it's OK to not have a "=value" part.
- if (def_optional && (flag_end[0] == '\0')) return flag_end;
-
- // If def_optional is true and there are more characters after the
- // flag name, or if def_optional is false, there must be a '=' after
- // the flag name.
- if (flag_end[0] != '=') return NULL;
-
- // Returns the string after "=".
- return flag_end + 1;
-}
-
-bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
- // Gets the value of the flag as a string.
- const char* const value_str = ParseFlagValue(str, flag, true);
-
- // Aborts if the parsing failed.
- if (value_str == NULL) return false;
-
- // Converts the string value to a bool.
- *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');
- return true;
-}
-
-bool ParseInt32Flag(const char* str, const char* flag, int32_t* value) {
- // Gets the value of the flag as a string.
- const char* const value_str = ParseFlagValue(str, flag, false);
-
- // Aborts if the parsing failed.
- if (value_str == NULL) return false;
-
- // Sets *value to the value of the flag.
- return ParseInt32(std::string("The value of flag --") + flag, value_str,
- value);
-}
-
-bool ParseDoubleFlag(const char* str, const char* flag, double* value) {
- // Gets the value of the flag as a string.
- const char* const value_str = ParseFlagValue(str, flag, false);
-
- // Aborts if the parsing failed.
- if (value_str == NULL) return false;
-
- // Sets *value to the value of the flag.
- return ParseDouble(std::string("The value of flag --") + flag, value_str,
- value);
-}
-
-bool ParseStringFlag(const char* str, const char* flag, std::string* value) {
- // Gets the value of the flag as a string.
- const char* const value_str = ParseFlagValue(str, flag, false);
-
- // Aborts if the parsing failed.
- if (value_str == NULL) return false;
-
- *value = value_str;
- return true;
-}
-
-bool IsFlag(const char* str, const char* flag) {
- return (ParseFlagValue(str, flag, true) != NULL);
-}
-} // end namespace benchmark
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/commandlineflags.h
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/commandlineflags.h b/third_party/benchmark/src/commandlineflags.h
deleted file mode 100644
index 34b9c6f..0000000
--- a/third_party/benchmark/src/commandlineflags.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef BENCHMARK_COMMANDLINEFLAGS_H_
-#define BENCHMARK_COMMANDLINEFLAGS_H_
-
-#include <cstdint>
-#include <string>
-
-// Macro for referencing flags.
-#define FLAG(name) FLAGS_##name
-
-// Macros for declaring flags.
-#define DECLARE_bool(name) extern bool FLAG(name)
-#define DECLARE_int32(name) extern int32_t FLAG(name)
-#define DECLARE_int64(name) extern int64_t FLAG(name)
-#define DECLARE_double(name) extern double FLAG(name)
-#define DECLARE_string(name) extern std::string FLAG(name)
-
-// Macros for defining flags.
-#define DEFINE_bool(name, default_val, doc) bool FLAG(name) = (default_val)
-#define DEFINE_int32(name, default_val, doc) int32_t FLAG(name) = (default_val)
-#define DEFINE_int64(name, default_val, doc) int64_t FLAG(name) = (default_val)
-#define DEFINE_double(name, default_val, doc) double FLAG(name) = (default_val)
-#define DEFINE_string(name, default_val, doc) \
- std::string FLAG(name) = (default_val)
-
-namespace benchmark {
-// Parses 'str' for a 32-bit signed integer. If successful, writes the result
-// to *value and returns true; otherwise leaves *value unchanged and returns
-// false.
-bool ParseInt32(const std::string& src_text, const char* str, int32_t* value);
-
-// Parses a bool/Int32/string from the environment variable
-// corresponding to the given Google Test flag.
-bool BoolFromEnv(const char* flag, bool default_val);
-int32_t Int32FromEnv(const char* flag, int32_t default_val);
-double DoubleFromEnv(const char* flag, double default_val);
-const char* StringFromEnv(const char* flag, const char* default_val);
-
-// Parses a string for a bool flag, in the form of either
-// "--flag=value" or "--flag".
-//
-// In the former case, the value is taken as true as long as it does
-// not start with '0', 'f', or 'F'.
-//
-// In the latter case, the value is taken as true.
-//
-// On success, stores the value of the flag in *value, and returns
-// true. On failure, returns false without changing *value.
-bool ParseBoolFlag(const char* str, const char* flag, bool* value);
-
-// Parses a string for an Int32 flag, in the form of
-// "--flag=value".
-//
-// On success, stores the value of the flag in *value, and returns
-// true. On failure, returns false without changing *value.
-bool ParseInt32Flag(const char* str, const char* flag, int32_t* value);
-
-// Parses a string for a Double flag, in the form of
-// "--flag=value".
-//
-// On success, stores the value of the flag in *value, and returns
-// true. On failure, returns false without changing *value.
-bool ParseDoubleFlag(const char* str, const char* flag, double* value);
-
-// Parses a string for a string flag, in the form of
-// "--flag=value".
-//
-// On success, stores the value of the flag in *value, and returns
-// true. On failure, returns false without changing *value.
-bool ParseStringFlag(const char* str, const char* flag, std::string* value);
-
-// Returns true if the string matches the flag.
-bool IsFlag(const char* str, const char* flag);
-
-} // end namespace benchmark
-
-#endif // BENCHMARK_COMMANDLINEFLAGS_H_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/cycleclock.h
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/cycleclock.h b/third_party/benchmark/src/cycleclock.h
deleted file mode 100644
index 5b28417..0000000
--- a/third_party/benchmark/src/cycleclock.h
+++ /dev/null
@@ -1,134 +0,0 @@
-// ----------------------------------------------------------------------
-// CycleClock
-// A CycleClock tells you the current time in Cycles. The "time"
-// is actually time since power-on. This is like time() but doesn't
-// involve a system call and is much more precise.
-//
-// NOTE: Not all cpu/platform/kernel combinations guarantee that this
-// clock increments at a constant rate or is synchronized across all logical
-// cpus in a system.
-//
-// If you need the above guarantees, please consider using a different
-// API. There are efforts to provide an interface which provides a millisecond
-// granularity and implemented as a memory read. A memory read is generally
-// cheaper than the CycleClock for many architectures.
-//
-// Also, in some out of order CPU implementations, the CycleClock is not
-// serializing. So if you're trying to count at cycles granularity, your
-// data might be inaccurate due to out of order instruction execution.
-// ----------------------------------------------------------------------
-
-#ifndef BENCHMARK_CYCLECLOCK_H_
-#define BENCHMARK_CYCLECLOCK_H_
-
-#include <cstdint>
-
-#include "benchmark/macros.h"
-#include "internal_macros.h"
-
-#if defined(OS_MACOSX)
-#include <mach/mach_time.h>
-#endif
-// For MSVC, we want to use '_asm rdtsc' when possible (since it works
-// with even ancient MSVC compilers), and when not possible the
-// __rdtsc intrinsic, declared in <intrin.h>. Unfortunately, in some
-// environments, <windows.h> and <intrin.h> have conflicting
-// declarations of some other intrinsics, breaking compilation.
-// Therefore, we simply declare __rdtsc ourselves. See also
-// http://connect.microsoft.com/VisualStudio/feedback/details/262047
-#if defined(COMPILER_MSVC) && !defined(_M_IX86)
-extern "C" uint64_t __rdtsc();
-#pragma intrinsic(__rdtsc)
-#endif
-#include <sys/time.h>
-
-namespace benchmark {
-// NOTE: only i386 and x86_64 have been well tested.
-// PPC, sparc, alpha, and ia64 are based on
-// http://peter.kuscsik.com/wordpress/?p=14
-// with modifications by m3b. See also
-// https://setisvn.ssl.berkeley.edu/svn/lib/fftw-3.0.1/kernel/cycle.h
-namespace cycleclock {
-// This should return the number of cycles since power-on. Thread-safe.
-inline BENCHMARK_ALWAYS_INLINE int64_t Now() {
-#if defined(OS_MACOSX)
- // this goes at the top because we need ALL Macs, regardless of
- // architecture, to return the number of "mach time units" that
- // have passed since startup. See sysinfo.cc where
- // InitializeSystemInfo() sets the supposed cpu clock frequency of
- // macs to the number of mach time units per second, not actual
- // CPU clock frequency (which can change in the face of CPU
- // frequency scaling). Also note that when the Mac sleeps, this
- // counter pauses; it does not continue counting, nor does it
- // reset to zero.
- return mach_absolute_time();
-#elif defined(__i386__)
- int64_t ret;
- __asm__ volatile("rdtsc" : "=A"(ret));
- return ret;
-#elif defined(__x86_64__) || defined(__amd64__)
- uint64_t low, high;
- __asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
- return (high << 32) | low;
-#elif defined(__powerpc__) || defined(__ppc__)
- // This returns a time-base, which is not always precisely a cycle-count.
- int64_t tbl, tbu0, tbu1;
- asm("mftbu %0" : "=r"(tbu0));
- asm("mftb %0" : "=r"(tbl));
- asm("mftbu %0" : "=r"(tbu1));
- tbl &= -static_cast<int64>(tbu0 == tbu1);
- // high 32 bits in tbu1; low 32 bits in tbl (tbu0 is garbage)
- return (tbu1 << 32) | tbl;
-#elif defined(__sparc__)
- int64_t tick;
- asm(".byte 0x83, 0x41, 0x00, 0x00");
- asm("mov %%g1, %0" : "=r"(tick));
- return tick;
-#elif defined(__ia64__)
- int64_t itc;
- asm("mov %0 = ar.itc" : "=r"(itc));
- return itc;
-#elif defined(COMPILER_MSVC) && defined(_M_IX86)
- // Older MSVC compilers (like 7.x) don't seem to support the
- // __rdtsc intrinsic properly, so I prefer to use _asm instead
- // when I know it will work. Otherwise, I'll use __rdtsc and hope
- // the code is being compiled with a non-ancient compiler.
- _asm rdtsc
-#elif defined(COMPILER_MSVC)
- return __rdtsc();
-#elif defined(__ARM_ARCH)
-#if (__ARM_ARCH >= 6) // V6 is the earliest arch that has a standard cyclecount
- uint32_t pmccntr;
- uint32_t pmuseren;
- uint32_t pmcntenset;
- // Read the user mode perf monitor counter access permissions.
- asm("mrc p15, 0, %0, c9, c14, 0" : "=r"(pmuseren));
- if (pmuseren & 1) { // Allows reading perfmon counters for user mode code.
- asm("mrc p15, 0, %0, c9, c12, 1" : "=r"(pmcntenset));
- if (pmcntenset & 0x80000000ul) { // Is it counting?
- asm("mrc p15, 0, %0, c9, c13, 0" : "=r"(pmccntr));
- // The counter is set up to count every 64th cycle
- return static_cast<int64_t>(pmccntr) * 64; // Should optimize to << 6
- }
- }
-#endif
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return static_cast<int64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
-#elif defined(__mips__)
- // mips apparently only allows rdtsc for superusers, so we fall
- // back to gettimeofday. It's possible clock_gettime would be better.
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return static_cast<int64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
-#else
-// The soft failover to a generic implementation is automatic only for ARM.
-// For other platforms the developer is expected to make an attempt to create
-// a fast implementation and use generic version if nothing better is available.
-#error You need to define CycleTimer for your OS and CPU
-#endif
-}
-} // end namespace cycleclock
-} // end namespace benchmark
-
-#endif // BENCHMARK_CYCLECLOCK_H_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/internal_macros.h
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/internal_macros.h b/third_party/benchmark/src/internal_macros.h
deleted file mode 100644
index 6667a2e..0000000
--- a/third_party/benchmark/src/internal_macros.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef BENCHMARK_INTERNAL_MACROS_H_
-#define BENCHMARK_INTERNAL_MACROS_H_
-
-#include "benchmark/macros.h"
-
-#ifndef __has_feature
-# define __has_feature(x) 0
-#endif
-
-#if __has_feature(cxx_attributes)
-# define BENCHMARK_NORETURN [[noreturn]]
-#elif defined(__GNUC__)
-# define BENCHMARK_NORETURN __attribute__((noreturn))
-#else
-# define BENCHMARK_NORETURN
-#endif
-
-#if defined(__CYGWIN__)
-# define OS_CYGWIN 1
-#elif defined(_WIN32)
-# define OS_WINDOWS 1
-#elif defined(__APPLE__)
-// TODO(ericwf) This doesn't actually check that it is a Mac OSX system. Just
-// that it is an apple system.
-# define OS_MACOSX 1
-#elif defined(__FreeBSD__)
-# define OS_FREEBSD 1
-#elif defined(__linux__)
-# define OS_LINUX 1
-#endif
-
-#if defined(__clang__)
-# define COMPILER_CLANG
-#elif defined(_MSC_VER)
-# define COMPILER_MSVC
-#elif defined(__GNUC__)
-# define COMPILER_GCC
-#endif
-
-#endif // BENCHMARK_INTERNAL_MACROS_H_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/log.cc
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/log.cc b/third_party/benchmark/src/log.cc
deleted file mode 100644
index b660309..0000000
--- a/third_party/benchmark/src/log.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "log.h"
-
-#include <iostream>
-
-namespace benchmark {
-namespace internal {
-
-int& LoggingLevelImp() {
- static int level = 0;
- return level;
-}
-
-void SetLogLevel(int value) {
- LoggingLevelImp() = value;
-}
-
-int GetLogLevel() {
- return LoggingLevelImp();
-}
-
-class NullLogBuffer : public std::streambuf
-{
-public:
- int overflow(int c) {
- return c;
- }
-};
-
-std::ostream& GetNullLogInstance() {
- static NullLogBuffer log_buff;
- static std::ostream null_log(&log_buff);
- return null_log;
-}
-
-std::ostream& GetErrorLogInstance() {
- return std::clog;
-}
-
-} // end namespace internal
-} // end namespace benchmark
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/log.h
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/log.h b/third_party/benchmark/src/log.h
deleted file mode 100644
index 3777810..0000000
--- a/third_party/benchmark/src/log.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef BENCHMARK_LOG_H_
-#define BENCHMARK_LOG_H_
-
-#include <ostream>
-
-namespace benchmark {
-namespace internal {
-
-int GetLogLevel();
-void SetLogLevel(int level);
-
-std::ostream& GetNullLogInstance();
-std::ostream& GetErrorLogInstance();
-
-inline std::ostream& GetLogInstanceForLevel(int level) {
- if (level <= GetLogLevel()) {
- return GetErrorLogInstance();
- }
- return GetNullLogInstance();
-}
-
-} // end namespace internal
-} // end namespace benchmark
-
-#define VLOG(x) (::benchmark::internal::GetLogInstanceForLevel(x) \
- << "-- LOG(" << x << "): ")
-
-#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/re.h
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/re.h b/third_party/benchmark/src/re.h
deleted file mode 100644
index 54117b1..0000000
--- a/third_party/benchmark/src/re.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 2015 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.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef BENCHMARK_RE_H_
-#define BENCHMARK_RE_H_
-
-#if defined(HAVE_STD_REGEX)
-#include <regex>
-#elif defined(HAVE_GNU_POSIX_REGEX)
-#include <gnuregex.h>
-#elif defined(HAVE_POSIX_REGEX)
-#include <regex.h>
-#else
-#error No regular expression backend was found!
-#endif
-#include <string>
-
-namespace benchmark {
-
-// A wrapper around the POSIX regular expression API that provides automatic
-// cleanup
-class Regex {
- public:
- Regex();
- ~Regex();
-
- // Compile a regular expression matcher from spec. Returns true on success.
- //
- // On failure (and if error is not NULL), error is populated with a human
- // readable error message if an error occurs.
- bool Init(const std::string& spec, std::string* error);
-
- // Returns whether str matches the compiled regular expression.
- bool Match(const std::string& str);
- private:
- bool init_;
- // Underlying regular expression object
-#if defined(HAVE_STD_REGEX)
- std::regex re_;
-#elif defined(HAVE_POSIX_REGEX) || defined(HAVE_GNU_POSIX_REGEX)
- regex_t re_;
-#else
-# error No regular expression backend implementation available
-#endif
-};
-
-} // end namespace benchmark
-
-#endif // BENCHMARK_RE_H_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/re_posix.cc
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/re_posix.cc b/third_party/benchmark/src/re_posix.cc
deleted file mode 100644
index e8fe1fc..0000000
--- a/third_party/benchmark/src/re_posix.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2015 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.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "check.h"
-#include "re.h"
-
-namespace benchmark {
-
-Regex::Regex() : init_(false) { }
-
-bool Regex::Init(const std::string& spec, std::string* error) {
- int ec = regcomp(&re_, spec.c_str(), REG_EXTENDED | REG_NOSUB);
- if (ec != 0) {
- if (error) {
- size_t needed = regerror(ec, &re_, NULL, 0);
- char* errbuf = new char[needed];
- regerror(ec, &re_, errbuf, needed);
-
- // regerror returns the number of bytes necessary to null terminate
- // the string, so we move that when assigning to error.
- CHECK_NE(needed, 0);
- error->assign(errbuf, needed - 1);
-
- delete[] errbuf;
- }
-
- return false;
- }
-
- init_ = true;
- return true;
-}
-
-Regex::~Regex() {
- if (init_) {
- regfree(&re_);
- }
-}
-
-bool Regex::Match(const std::string& str) {
- if (!init_) {
- return false;
- }
-
- return regexec(&re_, str.c_str(), 0, NULL, 0) == 0;
-}
-
-} // end namespace benchmark
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/re_std.cc
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/re_std.cc b/third_party/benchmark/src/re_std.cc
deleted file mode 100644
index cfd7a21..0000000
--- a/third_party/benchmark/src/re_std.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2015 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.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "re.h"
-
-namespace benchmark {
-
-Regex::Regex() : init_(false) { }
-
-bool Regex::Init(const std::string& spec, std::string* error) {
- try {
- re_ = std::regex(spec, std::regex_constants::extended);
-
- init_ = true;
- } catch (const std::regex_error& e) {
- if (error) {
- *error = e.what();
- }
- }
- return init_;
-}
-
-Regex::~Regex() { }
-
-bool Regex::Match(const std::string& str) {
- if (!init_) {
- return false;
- }
-
- return std::regex_search(str, re_);
-}
-
-} // end namespace benchmark
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/sleep.cc
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/sleep.cc b/third_party/benchmark/src/sleep.cc
deleted file mode 100644
index 4dfb4d9..0000000
--- a/third_party/benchmark/src/sleep.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2015 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.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "sleep.h"
-
-#include <cerrno>
-#include <ctime>
-
-#include "internal_macros.h"
-
-namespace benchmark {
-#ifdef OS_WINDOWS
-// Window's _sleep takes milliseconds argument.
-void SleepForMilliseconds(int milliseconds) { _sleep(milliseconds); }
-void SleepForSeconds(double seconds) {
- SleepForMilliseconds(static_cast<int>(kNumMillisPerSecond * seconds));
-}
-#else // OS_WINDOWS
-void SleepForMicroseconds(int microseconds) {
- struct timespec sleep_time;
- sleep_time.tv_sec = microseconds / kNumMicrosPerSecond;
- sleep_time.tv_nsec = (microseconds % kNumMicrosPerSecond) * kNumNanosPerMicro;
- while (nanosleep(&sleep_time, &sleep_time) != 0 && errno == EINTR)
- ; // Ignore signals and wait for the full interval to elapse.
-}
-
-void SleepForMilliseconds(int milliseconds) {
- SleepForMicroseconds(static_cast<int>(milliseconds) * kNumMicrosPerMilli);
-}
-
-void SleepForSeconds(double seconds) {
- SleepForMicroseconds(static_cast<int>(seconds * kNumMicrosPerSecond));
-}
-#endif // OS_WINDOWS
-} // end namespace benchmark
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/sleep.h
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/sleep.h b/third_party/benchmark/src/sleep.h
deleted file mode 100644
index f1e515c..0000000
--- a/third_party/benchmark/src/sleep.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef BENCHMARK_SLEEP_H_
-#define BENCHMARK_SLEEP_H_
-
-#include <cstdint>
-
-namespace benchmark {
-const int64_t kNumMillisPerSecond = 1000LL;
-const int64_t kNumMicrosPerMilli = 1000LL;
-const int64_t kNumMicrosPerSecond = kNumMillisPerSecond * 1000LL;
-const int64_t kNumNanosPerMicro = 1000LL;
-const int64_t kNumNanosPerSecond = kNumNanosPerMicro * kNumMicrosPerSecond;
-
-void SleepForMilliseconds(int milliseconds);
-void SleepForSeconds(double seconds);
-} // end namespace benchmark
-
-#endif // BENCHMARK_SLEEP_H_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/9661f956/third_party/benchmark/src/stat.h
----------------------------------------------------------------------
diff --git a/third_party/benchmark/src/stat.h b/third_party/benchmark/src/stat.h
deleted file mode 100644
index 435743c..0000000
--- a/third_party/benchmark/src/stat.h
+++ /dev/null
@@ -1,302 +0,0 @@
-#ifndef BENCHMARK_STAT_H_
-#define BENCHMARK_STAT_H_
-
-#include <cmath>
-#include <ostream>
-#include <limits>
-
-namespace benchmark {
-
-template <typename VType, typename NumType>
-class Stat1;
-
-template <typename VType, typename NumType>
-class Stat1MinMax;
-
-typedef Stat1<float, float> Stat1_f;
-typedef Stat1<double, double> Stat1_d;
-typedef Stat1MinMax<float, float> Stat1MinMax_f;
-typedef Stat1MinMax<double, double> Stat1MinMax_d;
-
-template <typename VType>
-class Vector2;
-template <typename VType>
-class Vector3;
-template <typename VType>
-class Vector4;
-
-template <typename VType, typename NumType>
-class Stat1 {
- public:
- typedef Stat1<VType, NumType> Self;
-
- Stat1() { Clear(); }
- // Create a sample of value dat and weight 1
- explicit Stat1(const VType &dat) {
- sum_ = dat;
- sum_squares_ = Sqr(dat);
- numsamples_ = 1;
- }
- // Create statistics for all the samples between begin (included)
- // and end(excluded)
- explicit Stat1(const VType *begin, const VType *end) {
- Clear();
- for (const VType *item = begin; item < end; ++item) {
- (*this) += Stat1(*item);
- }
- }
- // Create a sample of value dat and weight w
- Stat1(const VType &dat, const NumType &w) {
- sum_ = w * dat;
- sum_squares_ = w * Sqr(dat);
- numsamples_ = w;
- }
- // Copy operator
- Stat1(const Self &stat) {
- sum_ = stat.sum_;
- sum_squares_ = stat.sum_squares_;
- numsamples_ = stat.numsamples_;
- }
-
- void Clear() {
- numsamples_ = NumType();
- sum_squares_ = sum_ = VType();
- }
-
- 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) {
- sum_ += stat.sum_;
- sum_squares_ += stat.sum_squares_;
- numsamples_ += stat.numsamples_;
- return (*this);
- }
- // The operation opposite to +=
- 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) {
- sum_ *= k;
- sum_squares_ *= k;
- numsamples_ *= k;
- return (*this);
- }
-
- // Merge statistics from two sample sets.
- Self operator+(const Self &stat) const { return Self(*this) += stat; }
-
- // The operation opposite to +
- 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; }
-
- // Return the total weight of this sample set
- NumType numSamples() const { return numsamples_; }
-
- // Return the sum of this sample set
- VType Sum() const { return sum_; }
-
- // Return the mean of this sample set
- VType Mean() const {
- if (numsamples_ == 0) return VType();
- return sum_ * (1.0 / numsamples_);
- }
-
- // Return the mean of this sample set and compute the standard deviation at
- // the same time.
- VType Mean(VType *stddev) const {
- if (numsamples_ == 0) return VType();
- VType mean = sum_ * (1.0 / numsamples_);
- if (stddev) {
- VType avg_squares = sum_squares_ * (1.0 / numsamples_);
- *stddev = Sqrt(avg_squares - Sqr(mean));
- }
- return mean;
- }
-
- // Return the standard deviation of the sample set
- VType StdDev() const {
- if (numsamples_ == 0) return VType();
- VType mean = Mean();
- VType avg_squares = sum_squares_ * (1.0 / numsamples_);
- return Sqrt(avg_squares - Sqr(mean));
- }
-
- private:
- // Let i be the index of the samples provided (using +=)
- // and weight[i],value[i] be the data of sample #i
- // then the variables have the following meaning:
- NumType numsamples_; // sum of weight[i];
- VType sum_; // sum of weight[i]*value[i];
- VType sum_squares_; // sum of weight[i]*value[i]^2;
-
- // 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;
- }
-
- template <typename SType>
- static inline Vector2<SType> Sqr(const Vector2<SType> &dat) {
- return dat.MulComponents(dat);
- }
-
- template <typename SType>
- static inline Vector3<SType> Sqr(const Vector3<SType> &dat) {
- return dat.MulComponents(dat);
- }
-
- template <typename SType>
- static inline Vector4<SType> Sqr(const Vector4<SType> &dat) {
- return dat.MulComponents(dat);
- }
-
- // Template function used to take the square root of a number.
- // For a vector we square all components
- template <typename SType>
- static inline SType Sqrt(const SType &dat) {
- // Avoid NaN due to imprecision in the calculations
- if (dat < 0) return 0;
- return sqrt(dat);
- }
-
- template <typename SType>
- static inline Vector2<SType> Sqrt(const Vector2<SType> &dat) {
- // Avoid NaN due to imprecision in the calculations
- return Max(dat, Vector2<SType>()).Sqrt();
- }
-
- template <typename SType>
- static inline Vector3<SType> Sqrt(const Vector3<SType> &dat) {
- // Avoid NaN due to imprecision in the calculations
- return Max(dat, Vector3<SType>()).Sqrt();
- }
-
- template <typename SType>
- static inline Vector4<SType> Sqrt(const Vector4<SType> &dat) {
- // Avoid NaN due to imprecision in the calculations
- return Max(dat, Vector4<SType>()).Sqrt();
- }
-};
-
-// Useful printing function
-template <typename VType, typename NumType>
-std::ostream &operator<<(std::ostream &out, const Stat1<VType, NumType> &s) {
- out << "{ avg = " << s.Mean() << " std = " << s.StdDev()
- << " nsamples = " << s.NumSamples() << "}";
- return out;
-}
-
-// Stat1MinMax: same as Stat1, but it also
-// keeps the Min and Max values; the "-"
-// operator is disabled because it cannot be implemented
-// efficiently
-template <typename VType, typename NumType>
-class Stat1MinMax : public Stat1<VType, NumType> {
- public:
- typedef Stat1MinMax<VType, NumType> Self;
-
- Stat1MinMax() { Clear(); }
- // Create a sample of value dat and weight 1
- explicit Stat1MinMax(const VType &dat) : Stat1<VType, NumType>(dat) {
- max_ = dat;
- min_ = dat;
- }
- // Create statistics for all the samples between begin (included)
- // and end(excluded)
- explicit Stat1MinMax(const VType *begin, const VType *end) {
- Clear();
- for (const VType *item = begin; item < end; ++item) {
- (*this) += Stat1MinMax(*item);
- }
- }
- // Create a sample of value dat and weight w
- Stat1MinMax(const VType &dat, const NumType &w)
- : Stat1<VType, NumType>(dat, w) {
- max_ = dat;
- min_ = dat;
- }
- // Copy operator
- Stat1MinMax(const Self &stat) : Stat1<VType, NumType>(stat) {
- max_ = stat.max_;
- min_ = stat.min_;
- }
-
- void Clear() {
- Stat1<VType, NumType>::Clear();
- if (std::numeric_limits<VType>::has_infinity) {
- min_ = std::numeric_limits<VType>::infinity();
- max_ = -std::numeric_limits<VType>::infinity();
- } else {
- min_ = std::numeric_limits<VType>::max();
- max_ = std::numeric_limits<VType>::min();
- }
- }
-
- 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) {
- 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) {
- this->Stat1<VType, NumType>::operator*=(stat);
- return (*this);
- }
- // Merge statistics from two sample sets.
- 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; }
-
- // Return the maximal value in this sample set
- VType Max() const { return max_; }
- // Return the minimal value in this sample set
- VType Min() const { return min_; }
-
- private:
- // 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.
-
- // The operation opposite to -
- 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
- // then the variables have the following meaning:
- VType max_; // max of value[i]
- VType min_; // min of value[i]
-};
-
-// Useful printing function
-template <typename VType, typename NumType>
-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() << "}";
- return out;
-}
-} // end namespace benchmark
-
-#endif // BENCHMARK_STAT_H_