Commit f68e64c6 by Vadym Committed by Dominic Hamon

add support for step in DenseRange() (#260)

parent a2ca94dd
......@@ -489,9 +489,9 @@ public:
// REQUIRES: The function passed to the constructor must accept an arg1.
Benchmark* Range(int start, int limit);
// Run this benchmark once for every value in the range [start..limit]
// Run this benchmark once for all values in the range [start..limit] with specific step
// REQUIRES: The function passed to the constructor must accept an arg1.
Benchmark* DenseRange(int start, int limit);
Benchmark* DenseRange(int start, int limit, int step = 1);
// Run this benchmark once with "x,y" as the extra arguments passed
// to the function.
......
......@@ -354,7 +354,7 @@ public:
void Arg(int x);
void Unit(TimeUnit unit);
void Range(int start, int limit);
void DenseRange(int start, int limit);
void DenseRange(int start, int limit, int step = 1);
void ArgPair(int start, int limit);
void RangePair(int lo1, int hi1, int lo2, int hi2);
void RangeMultiplier(int multiplier);
......@@ -518,12 +518,12 @@ void BenchmarkImp::Range(int start, int limit) {
}
}
void BenchmarkImp::DenseRange(int start, int limit) {
void BenchmarkImp::DenseRange(int start, int limit, int step) {
CHECK(arg_count_ == -1 || arg_count_ == 1);
arg_count_ = 1;
CHECK_GE(start, 0);
CHECK_LE(start, limit);
for (int arg = start; arg <= limit; arg++) {
for (int arg = start; arg <= limit; arg += step) {
args_.emplace_back(arg, -1);
}
}
......@@ -655,8 +655,8 @@ Benchmark* Benchmark::Range(int start, int limit) {
return this;
}
Benchmark* Benchmark::DenseRange(int start, int limit) {
imp_->DenseRange(start, limit);
Benchmark* Benchmark::DenseRange(int start, int limit, int step) {
imp_->DenseRange(start, limit, step);
return this;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment