From: Michal Bloch Date: Wed, 8 Dec 2021 12:45:18 +0000 (+0100) Subject: Rearrange the libdbus test X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=96c4f1c4e650ee6fbeb9c23216d5772c70d5b4d0;p=platform%2Fcore%2Fsystem%2Fdbus-tools.git Rearrange the libdbus test Now it measures raw latency (without counting message wrangling overhead). Change-Id: Id8b4fe807c5c40d62d8398e03bd1f7681a491f76 Signed-off-by: Michal Bloch --- diff --git a/benchmark/libdbus.c b/benchmark/libdbus.c index 2beea9d..de4a445 100644 --- a/benchmark/libdbus.c +++ b/benchmark/libdbus.c @@ -38,23 +38,14 @@ static DBusHandlerResult message_func (DBusConnection *connection, //if (dbus_message_is_method_call (message, "org.libdbus.server", "Perf")) { - if(state->is_lt) - dbus_message_get_args (message, NULL, DBUS_TYPE_UINT64, &start, - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &state->buf, &msize, DBUS_TYPE_INVALID); - else - dbus_message_get_args (message, NULL, DBUS_TYPE_UINT64, &temp, - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &state->buf, &msize, DBUS_TYPE_INVALID); - - if(++cnt == state->iters) {cnt = 0; stop = true; } - - if(state->buf[0] != 'r') - return DBUS_HANDLER_RESULT_HANDLED; - if(state->is_lt) { clock_gettime (CLOCK_REALTIME, &clock); end = (unsigned long long)clock.tv_sec * NS +(unsigned long long)clock.tv_nsec; + dbus_message_get_args (message, NULL, DBUS_TYPE_UINT64, &start, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &state->buf, &msize, DBUS_TYPE_INVALID); + double lt = (double)(end - start) / 1000; if(lt) { @@ -66,8 +57,8 @@ static DBusHandlerResult message_func (DBusConnection *connection, if(lt < min) min = lt; } - } - else { + + } else { bw_cnt++; if(bw_cnt == 1) { clock_gettime (CLOCK_REALTIME, &clock); @@ -82,7 +73,15 @@ static DBusHandlerResult message_func (DBusConnection *connection, bw = ((unsigned long long)NS * bw_cnt)/(end - start); printf("bandwidth: %llu (/s)\n", bw); } + + dbus_message_get_args (message, NULL, DBUS_TYPE_UINT64, &temp, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &state->buf, &msize, DBUS_TYPE_INVALID); } + + if(++cnt == state->iters) {cnt = 0; stop = true; } + + if(state->buf[0] != 'r') + return DBUS_HANDLER_RESULT_HANDLED; } return DBUS_HANDLER_RESULT_HANDLED; } @@ -160,6 +159,12 @@ void Send(register int size, const char *name, const char *path, const char *cli else cptr[0] = 'w'; + + msg = dbus_message_new_method_call (name, path, name, "Perf"); + dbus_message_set_no_reply(msg, 1); + DBusMessageIter iter; + dbus_message_iter_init_append (msg, &iter); + if(is_lt) { clock_gettime (CLOCK_REALTIME, &clock); start = (unsigned long long)clock.tv_sec * NS @@ -168,14 +173,10 @@ void Send(register int size, const char *name, const char *path, const char *cli else start = 0; - msg = dbus_message_new_method_call (name, path, name, "Perf"); - DBusMessageIter iter; - dbus_message_iter_init_append (msg, &iter); dbus_message_append_args (msg, DBUS_TYPE_UINT64, &start, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &cptr, size, DBUS_TYPE_INVALID); - dbus_message_set_no_reply(msg, 1); dbus_connection_send (conn, msg, NULL); if(is_lt) {