19 #ifndef BENCHMARK_OS_WINDOWS
20 #include <sys/resource.h>
27 #include <condition_variable>
52 static const int kRangeMultiplier = 8;
55 static const size_t kMaxFamilySize = 100;
109 std::ostream* ErrStream) {
111 auto& Err = *ErrStream;
115 if (!re.
Init(spec, &error_msg)) {
116 Err <<
"Could not compile benchmark re: " << error_msg << std::endl;
121 const std::vector<int> one_thread = {1};
124 for (std::unique_ptr<Benchmark>& family :
families_) {
126 if (!family)
continue;
128 if (family->ArgsCnt() == -1) {
131 const std::vector<int>* thread_counts =
132 (family->thread_counts_.empty()
134 : &
static_cast<const std::vector<int>&
>(family->thread_counts_));
135 const size_t family_size = family->args_.size() * thread_counts->size();
138 if (family_size > kMaxFamilySize) {
139 Err <<
"The number of inputs is very large. " << family->name_
140 <<
" will be repeated at least " << family_size <<
" times.\n";
144 if (spec ==
".")
benchmarks->reserve(family_size);
146 for (
auto const&
args : family->args_) {
147 for (
int num_threads : *thread_counts) {
149 instance.
name = family->name_;
155 instance.
min_time = family->min_time_;
162 instance.
threads = num_threads;
166 for (
auto const& arg :
args) {
167 instance.
name +=
"/";
169 if (arg_i < family->arg_names_.size()) {
170 const auto& arg_name = family->arg_names_[arg_i];
171 if (!arg_name.empty()) {
181 if (!
IsZero(family->min_time_))
183 if (family->iterations_ != 0)
185 if (family->repetitions_ != 0)
188 if (family->use_manual_time_) {
189 instance.
name +=
"/manual_time";
190 }
else if (family->use_real_time_) {
191 instance.
name +=
"/real_time";
195 if (!family->thread_counts_.empty()) {
210 std::unique_ptr<Benchmark> bench_ptr(bench);
232 range_multiplier_(kRangeMultiplier),
236 use_real_time_(
false),
237 use_manual_time_(
false),
239 complexity_lambda_(nullptr) {}
251 static const int kint32max = std::numeric_limits<int32_t>::max();
279 std::vector<int> arglist;
282 for (
int i : arglist) {
290 std::vector<std::vector<int>> arglists(ranges.size());
291 std::size_t total = 1;
292 for (std::size_t
i = 0;
i < ranges.size();
i++) {
295 total *= arglists[
i].size();
298 std::vector<std::size_t> ctr(arglists.size(), 0);
300 for (std::size_t
i = 0;
i < total;
i++) {
301 std::vector<int> tmp;
302 tmp.reserve(arglists.size());
304 for (std::size_t j = 0; j < arglists.size(); j++) {
305 tmp.push_back(arglists[j].at(ctr[j]));
308 args_.push_back(std::move(tmp));
310 for (std::size_t j = 0; j < arglists.size(); j++) {
311 if (ctr[j] + 1 < arglists[j].
size()) {
337 for (
int arg =
start; arg <= limit; arg += step) {
338 args_.push_back({arg});
350 custom_arguments(
this);
355 CHECK(multiplier > 1);
389 <<
"Cannot set UseRealTime and UseManualTime simultaneously.";
396 <<
"Cannot set UseRealTime and UseManualTime simultaneously.";
432 for (
auto i = min_threads;
i < max_threads;
i +=
stride) {
440 static int num_cpus =
NumCPUs();
452 return static_cast<int>(
args_.front().size());