Skip to content

Commit

Permalink
test: bench_packet: implement test result export
Browse files Browse the repository at this point in the history
Newly added test result export functionality is now utilized in
odp_bench_packet.

Signed-off-by: Ray Sointula <[email protected]>
Reviewed-by: Matias Elo <[email protected]>
Reviewed-by: Tuomas Taipale <[email protected]>
  • Loading branch information
Rayska authored and MatiasElo committed Jun 25, 2024
1 parent 5ea305a commit 83f1a8c
Showing 1 changed file with 64 additions and 5 deletions.
69 changes: 64 additions & 5 deletions test/performance/odp_bench_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <odp/helper/odph_api.h>

#include <bench_common.h>
#include <export_results.h>

/** Packet user area size in bytes */
#define PKT_POOL_UAREA_SIZE 8
Expand Down Expand Up @@ -61,6 +62,11 @@
/** Default burst size for *_multi operations */
#define TEST_DEF_BURST 8

/** Maximum number of results to be held */
#define TEST_MAX_BENCH 100

#define TEST_MAX_SIZES 7

/** Get rid of path in filename - only for unix-type paths using '/' */
#define NO_PATH(file_name) (strrchr((file_name), '/') ? \
strrchr((file_name), '/') + 1 : (file_name))
Expand All @@ -75,6 +81,9 @@ ODP_STATIC_ASSERT((TEST_ALIGN_OFFSET + TEST_ALIGN_LEN) <= TEST_MIN_PKT_SIZE,
const uint32_t test_packet_len[] = {TEST_MIN_PKT_SIZE, 128, 256, 512,
1024, 1518, TEST_MAX_PKT_SIZE};

ODP_STATIC_ASSERT(ODPH_ARRAY_SIZE(test_packet_len) <= TEST_MAX_SIZES,
"Result array is too small to hold all the results");

/**
* Parsed command line arguments
*/
Expand Down Expand Up @@ -126,6 +135,10 @@ typedef struct {
odp_time_t ts_tbl[TEST_REPEAT_COUNT];
/** Array for storing test data */
uint8_t data_tbl[TEST_REPEAT_COUNT][TEST_MAX_PKT_SIZE];
/** Options for exporting results */
test_common_options_t common_options;
/** Array for storing results */
double result[TEST_MAX_SIZES][TEST_MAX_BENCH];
} args_t;

/** Global pointer to args */
Expand All @@ -138,6 +151,35 @@ static void sig_handler(int signo ODP_UNUSED)
odp_atomic_store_u32(&gbl_args->suite.exit_worker, 1);
}

static int bench_packet_export(void *data)
{
args_t *gbl_args = data;
int ret = 0;

if (test_common_write("%s", "Function name,64B,128B,256B,512B,1024B,1518B,2048B\n")) {
ret = -1;
goto exit;
}

for (int i = 0; i < gbl_args->suite.num_bench; i++) {
if (test_common_write("odp_%s,%f,%f,%f,%f,%f,%f,%f\n",
gbl_args->suite.bench[i].desc != NULL ?
gbl_args->suite.bench[i].desc : gbl_args->suite.bench[i].name,
gbl_args->result[0][i], gbl_args->result[1][i],
gbl_args->result[2][i], gbl_args->result[3][i],
gbl_args->result[4][i], gbl_args->result[5][i],
gbl_args->result[6][i])) {
ret = -1;
goto exit;
}
}

exit:
test_common_write_term();

return ret;
}

/**
* Master function for running the microbenchmarks
*/
Expand All @@ -147,16 +189,13 @@ static int run_benchmarks(void *arg)
args_t *args = arg;
bench_suite_t *suite = &args->suite;
int num_sizes = ODPH_ARRAY_SIZE(test_packet_len);
double results[num_sizes][suite->num_bench];

memset(results, 0, sizeof(results));

for (i = 0; i < num_sizes; i++) {
printf("Packet length: %6d bytes", test_packet_len[i]);

gbl_args->pkt.len = test_packet_len[i];

suite->result = results[i];
suite->result = args->result[i];

bench_run(suite);
}
Expand All @@ -174,9 +213,17 @@ static int run_benchmarks(void *arg)
suite->bench[i].desc : suite->bench[i].name);

for (int j = 0; j < num_sizes; j++)
printf("%8.1f ", results[j][i]);
printf("%8.1f ", args->result[j][i]);
}
printf("\n\n");

if (args->common_options.is_export) {
if (bench_packet_export(args)) {
ODPH_ERR("Error: Export failed\n");
return -1;
}
}

return 0;
}

Expand Down Expand Up @@ -1695,12 +1742,16 @@ bench_info_t test_suite[] = {
"packet_parse_multi ipv6/udp"),
};

ODP_STATIC_ASSERT(ODPH_ARRAY_SIZE(test_suite) < TEST_MAX_BENCH,
"Result array is too small to hold all the results");

/**
* ODP packet microbenchmark application
*/
int main(int argc, char *argv[])
{
odph_helper_options_t helper_options;
test_common_options_t common_options;
odph_thread_t worker_thread;
odph_thread_common_param_t thr_common;
odph_thread_param_t thr_param;
Expand All @@ -1722,6 +1773,12 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}

argc = test_common_parse_options(argc, argv);
if (test_common_options(&common_options)) {
ODPH_ERR("Error: reading test helper options failed\n");
exit(EXIT_FAILURE);
}

odp_init_param_init(&init_param);
init_param.mem_model = helper_options.mem_model;

Expand Down Expand Up @@ -1755,6 +1812,8 @@ int main(int argc, char *argv[])

memset(gbl_args, 0, sizeof(args_t));

gbl_args->common_options = common_options;

/* Parse and store the application arguments */
parse_args(argc, argv, &gbl_args->appl);

Expand Down

0 comments on commit 83f1a8c

Please sign in to comment.