From: Michal Bloch Date: Mon, 25 Mar 2024 17:32:06 +0000 (+0100) Subject: kdbus benchmark: use realtime clock instead of thread X-Git-Tag: accepted/tizen/unified/toolchain/20240610.173225~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65c37a5eb7cf2846ea8d2ec88cb693816a681a7b;p=platform%2Fkernel%2Flinux-tizen-modules-source.git kdbus benchmark: use realtime clock instead of thread * other benchmarks (binder; other kdbus tests from dbus-tools) use the REALTIME clock so we should use the same clock type. * using per-thread clock won't make much sense with more threads. Change-Id: I68ca1dd26466f6635385019d65b6815fa751972d Signed-off-by: Michal Bloch --- diff --git a/tests/kdbus/test-benchmark.c b/tests/kdbus/test-benchmark.c index 8b84671..f7c64a5 100644 --- a/tests/kdbus/test-benchmark.c +++ b/tests/kdbus/test-benchmark.c @@ -75,7 +75,7 @@ static void add_stats(uint64_t prev) { uint64_t diff, latency_avg_prev; - diff = now(CLOCK_THREAD_CPUTIME_ID) - prev; + diff = now(CLOCK_REALTIME) - prev; stats.count++; stats.latency_acc += diff; @@ -173,7 +173,7 @@ send_echo_request(struct kdbus_conn *conn, void *kdbus_msg, off_t memfd_item_off int ret; if (use_memfd) { - uint64_t now_ns = now(CLOCK_THREAD_CPUTIME_ID); + uint64_t now_ns = now(CLOCK_REALTIME); struct kdbus_item *item = memfd_item_offset + kdbus_msg; memfd = sys_memfd_create("memfd-name", 0); ASSERT_RETURN_VAL(memfd,>=,0, memfd); @@ -306,10 +306,10 @@ static wur int benchmark(struct kdbus_test_env *env) fds[0].fd = conn_a->fd; fds[1].fd = conn_b->fd; - start = now(CLOCK_THREAD_CPUTIME_ID); + start = now(CLOCK_REALTIME); reset_stats(); - send_ns = now(CLOCK_THREAD_CPUTIME_ID); + send_ns = now(CLOCK_REALTIME); ASSERT_ZERO(send_echo_request(conn_b, kdbus_msg, memfd_cached_offset)); while (1) { @@ -327,11 +327,11 @@ static wur int benchmark(struct kdbus_test_env *env) if (fds[0].revents & POLLIN) { ASSERT_ZERO(handle_echo_reply(conn_a, send_ns)); - send_ns = now(CLOCK_THREAD_CPUTIME_ID); + send_ns = now(CLOCK_REALTIME); ASSERT_ZERO(send_echo_request(conn_b, kdbus_msg, memfd_cached_offset)); } - now_ns = now(CLOCK_THREAD_CPUTIME_ID); + now_ns = now(CLOCK_REALTIME); diff = now_ns - start; if (diff > 1000000000ULL) { start = now_ns; @@ -353,10 +353,10 @@ static wur int benchmark(struct kdbus_test_env *env) /* cancel any pending message */ UNUSED(read(uds[1], buf, sizeof(buf))); - start = now(CLOCK_THREAD_CPUTIME_ID); + start = now(CLOCK_REALTIME); reset_stats(); - send_ns = now(CLOCK_THREAD_CPUTIME_ID); + send_ns = now(CLOCK_REALTIME); ASSERT_RETURN((typeof(write(uds[0], stress_payload, sizeof(stress_payload))))sizeof(stress_payload),==,write(uds[0], stress_payload, sizeof(stress_payload))); while (1) { @@ -376,11 +376,11 @@ static wur int benchmark(struct kdbus_test_env *env) add_stats(send_ns); - send_ns = now(CLOCK_THREAD_CPUTIME_ID); + send_ns = now(CLOCK_REALTIME); ASSERT_RETURN((typeof(write(uds[0], buf, sizeof(buf))))sizeof(buf),==,write(uds[0], buf, sizeof(buf))); } - now_ns = now(CLOCK_THREAD_CPUTIME_ID); + now_ns = now(CLOCK_REALTIME); diff = now_ns - start; if (diff > 1000000000ULL) { start = now_ns;