mirror of
https://github.com/google/benchmark.git
synced 2025-03-10 01:00:08 +08:00
add support for step in DenseRange() (#260)
This commit is contained in:
parent
a2ca94dd10
commit
f68e64c60a
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user