| 246 | } |
| 247 | |
| 248 | void Benchmark::RunWithFixedIters(int arg1, int arg2, int* run_count, double* run_seconds) { |
| 249 | env = Env::Default(); |
| 250 | static const int64 kMinIters = 100; |
| 251 | static const int64 kMaxIters = 1000000000; |
| 252 | static const double kMinTime = 0.5; |
| 253 | int iters = arg2; |
| 254 | // warming up |
| 255 | if (fn0_) { |
| 256 | (*fn0_)(100); |
| 257 | } else if (fn1_) { |
| 258 | (*fn1_)(100, arg1); |
| 259 | } else { |
| 260 | (*fn2_)(100, arg1, arg2); |
| 261 | } |
| 262 | accum_time = 0; |
| 263 | start_time = env->NowMicros(); |
| 264 | bytes_processed = -1; |
| 265 | items_processed = -1; |
| 266 | label.clear(); |
| 267 | if (fn0_) { |
| 268 | (*fn0_)(iters); |
| 269 | } else if (fn1_) { |
| 270 | (*fn1_)(iters, arg1); |
| 271 | } else { |
| 272 | (*fn2_)(iters, arg1, arg2); |
| 273 | } |
| 274 | StopTiming(); |
| 275 | const double seconds = accum_time * 1e-6; |
| 276 | *run_count = iters; |
| 277 | *run_seconds = seconds; |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | // TODO(vrv): Add support for running a subset of benchmarks by having |
| 282 | // RunBenchmarks take in a spec (and maybe other options such as |
no test coverage detected