Skip to content

Commit

Permalink
test: bench_misc: short and long time stamps
Browse files Browse the repository at this point in the history
Time stamp value may affect result of some test cases.
Also, test results are more consistent with fixed time
stamp values than currrent time (changes between test
runs). Added short (1 msec) and long (10 sec) time stamps,
and use those in short/long time_to_nsec test cases.

Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
  • Loading branch information
psavol committed Dec 4, 2023
1 parent 38e6c8e commit 899f192
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions test/performance/odp_bench_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,17 @@ typedef struct {
/* Common benchmark suite data */
bench_suite_t suite;

/* Test case input / output data */
/* Time stamp 1 */
odp_time_t t1[REPEAT_COUNT];
/* Time stamp 2 */
odp_time_t t2[REPEAT_COUNT];
/* Resulting time stamp */
odp_time_t t3[REPEAT_COUNT];

odp_time_t global_short[REPEAT_COUNT];
odp_time_t global_long[REPEAT_COUNT];

/* Integer input / output data */
uint64_t a1[REPEAT_COUNT];
uint64_t a2[REPEAT_COUNT];
uint32_t b1[REPEAT_COUNT];
Expand Down Expand Up @@ -266,14 +273,28 @@ static int time_sum(void)
return i;
}

static int time_to_ns(void)
static int time_to_ns_short(void)
{
int i;
odp_time_t *t1 = gbl_args->t1;
odp_time_t *t = gbl_args->global_short;
uint64_t res = 0;

for (i = 0; i < REPEAT_COUNT; i++)
res += odp_time_to_ns(t[i]);

gbl_args->suite.dummy += res;

return i;
}

static int time_to_ns_long(void)
{
int i;
odp_time_t *t = gbl_args->global_long;
uint64_t res = 0;

for (i = 0; i < REPEAT_COUNT; i++)
res += odp_time_to_ns(t1[i]);
res += odp_time_to_ns(t[i]);

gbl_args->suite.dummy += res;

Expand Down Expand Up @@ -698,7 +719,8 @@ bench_info_t test_suite[] = {
BENCH_INFO(time_diff, init_time_local, 0, "time_diff (local)"),
BENCH_INFO(time_diff_ns, init_time_global, 0, NULL),
BENCH_INFO(time_sum, init_time_global, 0, NULL),
BENCH_INFO(time_to_ns, init_time_global, 0, NULL),
BENCH_INFO(time_to_ns_short, NULL, 0, "time_to_ns (short)"),
BENCH_INFO(time_to_ns_long, NULL, 0, "time_to_ns (long)"),
BENCH_INFO(time_local_from_ns, init_time_global, 0, NULL),
BENCH_INFO(time_global_from_ns, init_time_global, 0, NULL),
BENCH_INFO(time_cmp, init_time_global, 0, NULL),
Expand Down Expand Up @@ -884,6 +906,8 @@ int main(int argc, char *argv[])
gbl_args->t1[i] = ODP_TIME_NULL;
gbl_args->t2[i] = ODP_TIME_NULL;
gbl_args->t3[i] = ODP_TIME_NULL;
gbl_args->global_short[i] = odp_time_global_from_ns(ODP_TIME_MSEC_IN_NS);
gbl_args->global_long[i] = odp_time_global_from_ns(10 * ODP_TIME_SEC_IN_NS);
gbl_args->a1[i] = i;
gbl_args->a2[i] = i;
gbl_args->b1[i] = i;
Expand Down

0 comments on commit 899f192

Please sign in to comment.