Skip to content

Commit

Permalink
test: bench_misc: add new tests
Browse files Browse the repository at this point in the history
Add new tests for CPU API functions odp_cpu_hz_id(), odp_cpu_hz_max_id(),
and odp_cpu_cycles_resolution().

Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
  • Loading branch information
MatiasElo committed Aug 23, 2023
1 parent 143df42 commit 9122a74
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion test/performance/odp_bench_misc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022, Nokia
/* Copyright (c) 2022-2023, Nokia
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
Expand Down Expand Up @@ -521,6 +521,18 @@ static int cpu_hz(void)
return i;
}

static int cpu_hz_id(void)
{
int i;
const int id = odp_cpu_id();
uint64_t *a1 = gbl_args->a1;

for (i = 0; i < REPEAT_COUNT; i++)
a1[i] = odp_cpu_hz_id(id);

return i;
}

static int cpu_hz_max(void)
{
int i;
Expand All @@ -532,6 +544,18 @@ static int cpu_hz_max(void)
return i;
}

static int cpu_hz_max_id(void)
{
int i;
const int id = odp_cpu_id();
uint64_t *a1 = gbl_args->a1;

for (i = 0; i < REPEAT_COUNT; i++)
a1[i] = odp_cpu_hz_max_id(id);

return i;
}

static int cpu_cycles(void)
{
int i;
Expand Down Expand Up @@ -569,6 +593,17 @@ static int cpu_cycles_max(void)
return i;
}

static int cpu_cycles_resolution(void)
{
int i;
uint64_t *a1 = gbl_args->a1;

for (i = 0; i < REPEAT_COUNT; i++)
a1[i] = odp_cpu_cycles_resolution();

return i;
}

static int cpu_pause(void)
{
int i;
Expand Down Expand Up @@ -819,10 +854,13 @@ bench_info_t test_suite[] = {
BENCH_INFO(cpu_id, NULL, 0, NULL),
BENCH_INFO(cpu_count, NULL, 0, NULL),
BENCH_INFO(cpu_hz, NULL, 1, NULL),
BENCH_INFO(cpu_hz_id, NULL, 1, NULL),
BENCH_INFO(cpu_hz_max, NULL, 0, NULL),
BENCH_INFO(cpu_hz_max_id, NULL, 0, NULL),
BENCH_INFO(cpu_cycles, NULL, 0, NULL),
BENCH_INFO(cpu_cycles_diff, init_cpu_cycles, 0, NULL),
BENCH_INFO(cpu_cycles_max, NULL, 0, NULL),
BENCH_INFO(cpu_cycles_resolution, NULL, 0, NULL),
BENCH_INFO(cpu_pause, NULL, 0, NULL),
BENCH_INFO(thread_id, NULL, 0, NULL),
BENCH_INFO(thread_count, NULL, 0, NULL),
Expand Down

0 comments on commit 9122a74

Please sign in to comment.