Skip to content

Commit

Permalink
test: bench_pktio_sp: add new test for creating pmr rules
Browse files Browse the repository at this point in the history
Add new test case 'cls_create_pmr', which creates a selected number ('-p')
of PMRs.

bench_tm_func_record() saves now also the number of measurements, which
makes the usage more flexible. Optional precondition check function 'cond'
was added to bench_tm_info_t to enable skipping unsupported tests.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
  • Loading branch information
MatiasElo committed Oct 11, 2023
1 parent e554204 commit 6f57d1e
Show file tree
Hide file tree
Showing 3 changed files with 280 additions and 83 deletions.
17 changes: 14 additions & 3 deletions test/performance/bench_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ void bench_tm_func_record(odp_time_t t2, odp_time_t t1, bench_tm_result_t *res,

if (odp_time_cmp(diff, res->func[id].max) > 0)
res->func[id].max = diff;

res->func[id].num++;
}

static void init_result(bench_tm_result_t *res)
Expand All @@ -183,13 +185,15 @@ static void init_result(bench_tm_result_t *res)
}
}

static void print_results(bench_tm_result_t *res, uint64_t repeat_count)
static void print_results(bench_tm_result_t *res)
{
for (uint8_t i = 0; i < res->num; i++) {
uint64_t num = res->func[i].num ? res->func[i].num : 1;

printf(" %-38s %-12" PRIu64 " %-12" PRIu64 " %-12" PRIu64 "\n",
res->func[i].name,
odp_time_to_ns(res->func[i].min),
odp_time_to_ns(res->func[i].tot) / repeat_count,
odp_time_to_ns(res->func[i].tot) / num,
odp_time_to_ns(res->func[i].max));
}
}
Expand Down Expand Up @@ -218,6 +222,13 @@ int bench_tm_run(void *arg)
if (bench->max_rounds && bench->max_rounds < rounds)
rounds = bench->max_rounds;

if (bench->cond != NULL && !bench->cond()) {
if (i > 0)
printf("[%02d] %-41s n/a n/a n/a\n",
j + 1, bench->name);
continue;
}

init_result(&res);

if (bench->init != NULL)
Expand All @@ -235,7 +246,7 @@ int bench_tm_run(void *arg)
/* No print or results from warm-up round */
if (i > 0) {
printf("[%02d] %-26s\n", j + 1, bench->name);
print_results(&res, rounds);
print_results(&res);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions test/performance/bench_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ typedef struct bench_tm_results_s {
/* Maximum duration */
odp_time_t max;

/* Number of measurements */
uint64_t num;

} func[BENCH_TM_MAX_FUNC];

/* Number of registered test functions */
Expand All @@ -159,6 +162,9 @@ typedef struct {
/* Test case name */
const char *name;

/* Optional precondition to run test */
bench_cond_fn_t cond;

/* Optional test initializer function */
bench_init_fn_t init;

Expand Down
Loading

0 comments on commit 6f57d1e

Please sign in to comment.