[v7,11/17] test/ring: modify burst enq/deq perf test cases
Checks
Commit Message
Add test cases to test legacy and rte_ring_xxx_elem APIs for
burst enqueue/dequeue test cases.
Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
---
app/test/test_ring_perf.c | 78 ++++++++++++++++++++-------------------
1 file changed, 40 insertions(+), 38 deletions(-)
Comments
>
> Add test cases to test legacy and rte_ring_xxx_elem APIs for
> burst enqueue/dequeue test cases.
>
> Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> Reviewed-by: Gavin Hu <gavin.hu@arm.com>
> ---
> app/test/test_ring_perf.c | 78 ++++++++++++++++++++-------------------
> 1 file changed, 40 insertions(+), 38 deletions(-)
>
> diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
> index 5829718c1..508c688dc 100644
> --- a/app/test/test_ring_perf.c
> +++ b/app/test/test_ring_perf.c
> @@ -397,47 +397,40 @@ test_single_enqueue_dequeue(struct rte_ring *r, const int esize,
> }
>
> /*
> - * Test that does both enqueue and dequeue on a core using the burst() API calls
> - * instead of the bulk() calls used in other tests. Results should be the same
> - * as for the bulk function called on a single lcore.
> + * Test that does both enqueue and dequeue on a core using the burst/bulk API
> + * calls Results should be the same as for the bulk function called on a
> + * single lcore.
> */
> -static void
> -test_burst_enqueue_dequeue(struct rte_ring *r)
> +static int
> +test_burst_bulk_enqueue_dequeue(struct rte_ring *r, const int esize,
> + const unsigned int api_type)
> {
> - const unsigned iter_shift = 23;
> - const unsigned iterations = 1<<iter_shift;
> - unsigned sz, i = 0;
> - void *burst[MAX_BURST] = {0};
> + int ret;
> + const unsigned int iter_shift = 23;
> + const unsigned int iterations = 1 << iter_shift;
> + unsigned int sz, i = 0;
> + void **burst = NULL;
>
> - for (sz = 0; sz < sizeof(bulk_sizes)/sizeof(bulk_sizes[0]); sz++) {
> - const uint64_t sc_start = rte_rdtsc();
> - for (i = 0; i < iterations; i++) {
> - rte_ring_sp_enqueue_burst(r, burst,
> - bulk_sizes[sz], NULL);
> - rte_ring_sc_dequeue_burst(r, burst,
> - bulk_sizes[sz], NULL);
> - }
> - const uint64_t sc_end = rte_rdtsc();
> + (void)ret;
> + burst = test_ring_calloc(MAX_BURST, esize);
> + if (burst == NULL)
> + return -1;
>
> - const uint64_t mc_start = rte_rdtsc();
> + for (sz = 0; sz < RTE_DIM(bulk_sizes); sz++) {
> + const uint64_t start = rte_rdtsc();
> for (i = 0; i < iterations; i++) {
> - rte_ring_mp_enqueue_burst(r, burst,
> - bulk_sizes[sz], NULL);
> - rte_ring_mc_dequeue_burst(r, burst,
> - bulk_sizes[sz], NULL);
> + TEST_RING_ENQUEUE(r, burst, esize, bulk_sizes[sz],
> + ret, api_type);
> + TEST_RING_DEQUEUE(r, burst, esize, bulk_sizes[sz],
> + ret, api_type);
> }
> - const uint64_t mc_end = rte_rdtsc();
> -
> - double mc_avg = ((double)(mc_end-mc_start) / iterations) /
> - bulk_sizes[sz];
> - double sc_avg = ((double)(sc_end-sc_start) / iterations) /
> - bulk_sizes[sz];
> + const uint64_t end = rte_rdtsc();
>
> - printf("SP/SC burst enq/dequeue (size: %u): %.2F\n",
> - bulk_sizes[sz], sc_avg);
> - printf("MP/MC burst enq/dequeue (size: %u): %.2F\n",
> - bulk_sizes[sz], mc_avg);
> + test_ring_print_test_string(api_type, esize, bulk_sizes[sz],
> + ((double)(end - start)) / iterations);
> }
> +
missing rte_free(burst);
?
> + return 0;
> }
>
<snip>
> >
> > Add test cases to test legacy and rte_ring_xxx_elem APIs for burst
> > enqueue/dequeue test cases.
> >
> > Signed-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> > Reviewed-by: Gavin Hu <gavin.hu@arm.com>
> > ---
> > app/test/test_ring_perf.c | 78
> > ++++++++++++++++++++-------------------
> > 1 file changed, 40 insertions(+), 38 deletions(-)
> >
> > diff --git a/app/test/test_ring_perf.c b/app/test/test_ring_perf.c
> > index 5829718c1..508c688dc 100644
> > --- a/app/test/test_ring_perf.c
> > +++ b/app/test/test_ring_perf.c
> > @@ -397,47 +397,40 @@ test_single_enqueue_dequeue(struct rte_ring *r,
> > const int esize, }
> >
> > /*
> > - * Test that does both enqueue and dequeue on a core using the
> > burst() API calls
> > - * instead of the bulk() calls used in other tests. Results should be
> > the same
> > - * as for the bulk function called on a single lcore.
> > + * Test that does both enqueue and dequeue on a core using the
> > + burst/bulk API
> > + * calls Results should be the same as for the bulk function called
> > + on a
> > + * single lcore.
> > */
> > -static void
> > -test_burst_enqueue_dequeue(struct rte_ring *r)
> > +static int
> > +test_burst_bulk_enqueue_dequeue(struct rte_ring *r, const int esize,
> > + const unsigned int api_type)
> > {
> > - const unsigned iter_shift = 23;
> > - const unsigned iterations = 1<<iter_shift;
> > - unsigned sz, i = 0;
> > - void *burst[MAX_BURST] = {0};
> > + int ret;
> > + const unsigned int iter_shift = 23;
> > + const unsigned int iterations = 1 << iter_shift;
> > + unsigned int sz, i = 0;
> > + void **burst = NULL;
> >
> > - for (sz = 0; sz < sizeof(bulk_sizes)/sizeof(bulk_sizes[0]); sz++) {
> > - const uint64_t sc_start = rte_rdtsc();
> > - for (i = 0; i < iterations; i++) {
> > - rte_ring_sp_enqueue_burst(r, burst,
> > - bulk_sizes[sz], NULL);
> > - rte_ring_sc_dequeue_burst(r, burst,
> > - bulk_sizes[sz], NULL);
> > - }
> > - const uint64_t sc_end = rte_rdtsc();
> > + (void)ret;
> > + burst = test_ring_calloc(MAX_BURST, esize);
> > + if (burst == NULL)
> > + return -1;
> >
> > - const uint64_t mc_start = rte_rdtsc();
> > + for (sz = 0; sz < RTE_DIM(bulk_sizes); sz++) {
> > + const uint64_t start = rte_rdtsc();
> > for (i = 0; i < iterations; i++) {
> > - rte_ring_mp_enqueue_burst(r, burst,
> > - bulk_sizes[sz], NULL);
> > - rte_ring_mc_dequeue_burst(r, burst,
> > - bulk_sizes[sz], NULL);
> > + TEST_RING_ENQUEUE(r, burst, esize, bulk_sizes[sz],
> > + ret, api_type);
> > + TEST_RING_DEQUEUE(r, burst, esize, bulk_sizes[sz],
> > + ret, api_type);
> > }
> > - const uint64_t mc_end = rte_rdtsc();
> > -
> > - double mc_avg = ((double)(mc_end-mc_start) / iterations) /
> > - bulk_sizes[sz];
> > - double sc_avg = ((double)(sc_end-sc_start) / iterations) /
> > - bulk_sizes[sz];
> > + const uint64_t end = rte_rdtsc();
> >
> > - printf("SP/SC burst enq/dequeue (size: %u): %.2F\n",
> > - bulk_sizes[sz], sc_avg);
> > - printf("MP/MC burst enq/dequeue (size: %u): %.2F\n",
> > - bulk_sizes[sz], mc_avg);
> > + test_ring_print_test_string(api_type, esize, bulk_sizes[sz],
> > + ((double)(end - start)) / iterations);
> > }
> > +
>
> missing rte_free(burst);
> ?
Yes, will fix.
>
> > + return 0;
> > }
> >
@@ -397,47 +397,40 @@ test_single_enqueue_dequeue(struct rte_ring *r, const int esize,
}
/*
- * Test that does both enqueue and dequeue on a core using the burst() API calls
- * instead of the bulk() calls used in other tests. Results should be the same
- * as for the bulk function called on a single lcore.
+ * Test that does both enqueue and dequeue on a core using the burst/bulk API
+ * calls Results should be the same as for the bulk function called on a
+ * single lcore.
*/
-static void
-test_burst_enqueue_dequeue(struct rte_ring *r)
+static int
+test_burst_bulk_enqueue_dequeue(struct rte_ring *r, const int esize,
+ const unsigned int api_type)
{
- const unsigned iter_shift = 23;
- const unsigned iterations = 1<<iter_shift;
- unsigned sz, i = 0;
- void *burst[MAX_BURST] = {0};
+ int ret;
+ const unsigned int iter_shift = 23;
+ const unsigned int iterations = 1 << iter_shift;
+ unsigned int sz, i = 0;
+ void **burst = NULL;
- for (sz = 0; sz < sizeof(bulk_sizes)/sizeof(bulk_sizes[0]); sz++) {
- const uint64_t sc_start = rte_rdtsc();
- for (i = 0; i < iterations; i++) {
- rte_ring_sp_enqueue_burst(r, burst,
- bulk_sizes[sz], NULL);
- rte_ring_sc_dequeue_burst(r, burst,
- bulk_sizes[sz], NULL);
- }
- const uint64_t sc_end = rte_rdtsc();
+ (void)ret;
+ burst = test_ring_calloc(MAX_BURST, esize);
+ if (burst == NULL)
+ return -1;
- const uint64_t mc_start = rte_rdtsc();
+ for (sz = 0; sz < RTE_DIM(bulk_sizes); sz++) {
+ const uint64_t start = rte_rdtsc();
for (i = 0; i < iterations; i++) {
- rte_ring_mp_enqueue_burst(r, burst,
- bulk_sizes[sz], NULL);
- rte_ring_mc_dequeue_burst(r, burst,
- bulk_sizes[sz], NULL);
+ TEST_RING_ENQUEUE(r, burst, esize, bulk_sizes[sz],
+ ret, api_type);
+ TEST_RING_DEQUEUE(r, burst, esize, bulk_sizes[sz],
+ ret, api_type);
}
- const uint64_t mc_end = rte_rdtsc();
-
- double mc_avg = ((double)(mc_end-mc_start) / iterations) /
- bulk_sizes[sz];
- double sc_avg = ((double)(sc_end-sc_start) / iterations) /
- bulk_sizes[sz];
+ const uint64_t end = rte_rdtsc();
- printf("SP/SC burst enq/dequeue (size: %u): %.2F\n",
- bulk_sizes[sz], sc_avg);
- printf("MP/MC burst enq/dequeue (size: %u): %.2F\n",
- bulk_sizes[sz], mc_avg);
+ test_ring_print_test_string(api_type, esize, bulk_sizes[sz],
+ ((double)(end - start)) / iterations);
}
+
+ return 0;
}
/* Times enqueue and dequeue on a single lcore */
@@ -499,7 +492,13 @@ test_ring_perf(void)
return -1;
if (test_single_enqueue_dequeue(r, -1, TEST_RING_M | TEST_RING_SL) < 0)
return -1;
-
+ printf("\n### Testing burst enq/deq ###\n");
+ if (test_burst_bulk_enqueue_dequeue(r, -1,
+ TEST_RING_S | TEST_RING_BR) < 0)
+ return -1;
+ if (test_burst_bulk_enqueue_dequeue(r, -1,
+ TEST_RING_M | TEST_RING_BR) < 0)
+ return -1;
rte_ring_free(r);
TEST_RING_CREATE(RING_NAME, 16, RING_SIZE, rte_socket_id(), 0, r);
@@ -511,16 +510,19 @@ test_ring_perf(void)
return -1;
if (test_single_enqueue_dequeue(r, 16, TEST_RING_M | TEST_RING_SL) < 0)
return -1;
-
+ printf("\n### Testing burst enq/deq ###\n");
+ if (test_burst_bulk_enqueue_dequeue(r, 16,
+ TEST_RING_S | TEST_RING_BR) < 0)
+ return -1;
+ if (test_burst_bulk_enqueue_dequeue(r, 16,
+ TEST_RING_M | TEST_RING_BR) < 0)
+ return -1;
rte_ring_free(r);
r = rte_ring_create(RING_NAME, RING_SIZE, rte_socket_id(), 0);
if (r == NULL)
return -1;
- printf("### Testing single element and burst enq/deq ###\n");
- test_burst_enqueue_dequeue(r);
-
printf("\n### Testing empty dequeue ###\n");
test_empty_dequeue(r);