1 #ifndef BENCHMARK_REGISTER_H 2 #define BENCHMARK_REGISTER_H 3 4 #include <vector> 5 6 #include "check.h" 7 8 template <typename T> AddRange(std::vector<T> * dst,T lo,T hi,int mult)9void AddRange(std::vector<T>* dst, T lo, T hi, int mult) { 10 CHECK_GE(lo, 0); 11 CHECK_GE(hi, lo); 12 CHECK_GE(mult, 2); 13 14 // Add "lo" 15 dst->push_back(lo); 16 17 static const T kmax = std::numeric_limits<T>::max(); 18 19 // Now space out the benchmarks in multiples of "mult" 20 for (T i = 1; i < kmax / mult; i *= mult) { 21 if (i >= hi) break; 22 if (i > lo) { 23 dst->push_back(i); 24 } 25 } 26 27 // Add "hi" (if different from "lo") 28 if (hi != lo) { 29 dst->push_back(hi); 30 } 31 } 32 33 #endif // BENCHMARK_REGISTER_H 34