Skip to content

Commit

Permalink
test: bench_common: fix running selected test indefinitely
Browse files Browse the repository at this point in the history
The benchmark index 'j' is already incremented in the for loop, so remove
the extra increment which caused every other index to be skipped. Rename
variable 'j' to 'i' for consistency.

Signed-off-by: Matias Elo <[email protected]>
Reviewed-by: Tuomas Taipale <[email protected]>
  • Loading branch information
MatiasElo committed Jul 5, 2024
1 parent e7db3bd commit df5f890
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions test/common/bench_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ int bench_run(void *arg)
printf("\nAverage %s per function call\n", meas_time ? "time (nsec)" : "CPU cycles");
printf("-------------------------------------------------\n");

for (int j = 0; j < suite->num_bench; j++) {
for (int i = 0; i < suite->num_bench; i++) {
int ret;
const char *desc;
const bench_info_t *bench = &suite->bench[j];
const bench_info_t *bench = &suite->bench[i];
uint64_t max_rounds = suite->rounds;
uint64_t total = 0;

Expand All @@ -70,11 +70,10 @@ int bench_run(void *arg)

/* Run selected test indefinitely */
if (suite->indef_idx) {
if ((j + 1) != suite->indef_idx) {
j++;
if ((i + 1) != suite->indef_idx)
continue;
}
bench_run_indef(&suite->bench[j], &suite->exit_worker);

bench_run_indef(&suite->bench[i], &suite->exit_worker);
return 0;
}

Expand Down Expand Up @@ -117,9 +116,9 @@ int bench_run(void *arg)
/* Each benchmark runs internally 'repeat_count' times. */
result = ((double)total) / (max_rounds * repeat_count);

printf("[%02d] odp_%-26s: %12.2f\n", j + 1, desc, result);
printf("[%02d] odp_%-26s: %12.2f\n", i + 1, desc, result);
if (suite->result)
suite->result[j] = result;
suite->result[i] = result;
}
printf("\n");
/* Print dummy result to prevent compiler to optimize it away*/
Expand Down

0 comments on commit df5f890

Please sign in to comment.