diff --git a/src/bench.rs b/src/bench.rs index 232ec07..ff63f1c 100644 --- a/src/bench.rs +++ b/src/bench.rs @@ -706,6 +706,12 @@ fn bench_worker_regular(map: Arc>, context: WorkerContext) { // start benchmark loop { + // check if we need to break + if bench_repeat_should_break(&benchmark.len, *counter, start, &mut workload) { + workload.reset(); + break; + } + let op = workload.next(&mut rng); let op_start = latency_tick(); match op { @@ -731,12 +737,6 @@ fn bench_worker_regular(map: Arc>, context: WorkerContext) { if let Some(r) = &rate_limiter { r.backoff(*counter); } - - // check if we need to break - if bench_repeat_should_break(&benchmark.len, *counter, start, &mut workload) { - workload.reset(); - break; - } } // after the execution, counter is up-to-date, so it's time to update duration @@ -831,6 +831,11 @@ fn bench_worker_async(map: Arc>, context: WorkerContext) { requests.clear(); // sample requests for _ in 0..benchmark.batch { + // stop the batch generation if the repeat is done + if bench_repeat_should_break(&benchmark.len, *counter, start, &mut workload) { + break; + } + let op = workload.next(&mut rng); requests.push(Request { id: rid, op }); rid += 1; @@ -838,10 +843,6 @@ fn bench_worker_async(map: Arc>, context: WorkerContext) { // otherwise the last check may fail because the time check is after a certain // interval, but the mod is never 0 *counter += 1; - // stop the batch generation if the repeat is done - if bench_repeat_should_break(&benchmark.len, *counter, start, &mut workload) { - break; - } // if a rate limiter is in place and no further backoff is needed, break early to // send the batch immediately if let Some(r) = &rate_limiter { diff --git a/src/workload.rs b/src/workload.rs index c392fbd..2ad044d 100644 --- a/src/workload.rs +++ b/src/workload.rs @@ -354,7 +354,7 @@ impl Workload { } pub fn is_exhausted(&self) -> bool { - self.kgen.serial == (self.kgen.max - self.kgen.min) + self.kgen.serial == self.kgen.keyspace } }