libdbus: fix real tries counting bug 94/270394/1
authorAdam Michalski <a.michalski2@partner.samsung.com>
Mon, 31 Jan 2022 16:06:57 +0000 (17:06 +0100)
committerAdam Michalski <a.michalski2@partner.samsung.com>
Mon, 31 Jan 2022 16:06:57 +0000 (17:06 +0100)
Fixes a bug causing warm-up tries to be treated as real tries in
latency calculations.

Change-Id: I1548a162fffa6830cf589ebc46bcc571dcfc399b

benchmark/libdbus.c

index 06d534301ede9c0b5fa899defede3434a9e53dba..ec34c93d54df5b478ddb9f21bca075dc33f9d6de 100644 (file)
@@ -38,6 +38,7 @@ static DBusHandlerResult message_func (DBusConnection *connection,
        unsigned long long end;
        unsigned long long temp;
        struct timespec clock;
+       double lt = 0;
        State *state = (State *)user_data;
 
        //if (dbus_message_is_method_call (message, "org.libdbus.server", "Perf"))
@@ -50,20 +51,7 @@ static DBusHandlerResult message_func (DBusConnection *connection,
                        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 (raw_data_on)
-                               fprintf(raw_data_fd, "%0.4f\n", lt);
-
-                       if(lt) {
-                               lt_cnt++;
-                               total += lt;
-                               if(lt > max)
-                                       max = lt;
-
-                               if(lt < min)
-                                       min = lt;
-                       }
+                       lt = (double)(end - start) / 1000;
 
                } else {
                        bw_cnt++;
@@ -89,6 +77,21 @@ static DBusHandlerResult message_func (DBusConnection *connection,
 
                if(state->buf[0] != 'r')
                        return DBUS_HANDLER_RESULT_HANDLED;
+
+               if (state->is_lt) {
+                       if (raw_data_on)
+                               fprintf(raw_data_fd, "%0.4f\n", lt);
+
+                       if(lt > 0) {
+                               lt_cnt++;
+                               total += lt;
+                               if(lt > max)
+                                       max = lt;
+
+                               if(lt < min)
+                                       min = lt;
+                       }
+               }
        }
        return DBUS_HANDLER_RESULT_HANDLED;
 }