test/service: add perf test for service on app lcore
authorHarry van Haaren <harry.van.haaren@intel.com>
Wed, 6 May 2020 17:16:42 +0000 (18:16 +0100)
committerDavid Marchand <david.marchand@redhat.com>
Mon, 11 May 2020 07:33:45 +0000 (09:33 +0200)
This commit adds a basic test to check the cycle cost
of related to calling into a service.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Tested-by: Phil Yang <phil.yang@arm.com>
Reviewed-by: Phil Yang <phil.yang@arm.com>
app/test/test_service_cores.c

index a922c7d..981e212 100644 (file)
@@ -789,8 +789,19 @@ service_app_lcore_poll_impl(const int mt_safe)
                                "MT Unsafe: App core1 didn't return -EBUSY");
        }
 
-       unregister_all();
+       /* Performance test: call in a loop, and measure tsc() */
+       const uint32_t perf_iters = (1 << 12);
+       uint64_t start = rte_rdtsc();
+       uint32_t i;
+       for (i = 0; i < perf_iters; i++) {
+               int err = service_run_on_app_core_func(&id);
+               TEST_ASSERT_EQUAL(0, err, "perf test: returned run failure");
+       }
+       uint64_t end = rte_rdtsc();
+       printf("perf test for %s: %0.1f cycles per call\n", mt_safe ?
+               "MT Safe" : "MT Unsafe", (end - start)/(float)perf_iters);
 
+       unregister_all();
        return TEST_SUCCESS;
 }