Rearrange the libdbus test 82/267682/1
authorMichal Bloch <m.bloch@samsung.com>
Wed, 8 Dec 2021 12:45:18 +0000 (13:45 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Wed, 8 Dec 2021 13:14:52 +0000 (14:14 +0100)
Now it measures raw latency (without counting message wrangling overhead).

Change-Id: Id8b4fe807c5c40d62d8398e03bd1f7681a491f76
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
benchmark/libdbus.c

index 2beea9ddd6afabb42e72cc4e0406a159f4940375..de4a44566c7e9bc1caab6716447bd3f3f04a6e36 100644 (file)
@@ -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) {