Rearrange gdbus and peer to peer gdbus tests 85/270285/1
authorAdam Michalski <a.michalski2@partner.samsung.com>
Thu, 27 Jan 2022 11:30:42 +0000 (12:30 +0100)
committerAdam Michalski <a.michalski2@partner.samsung.com>
Thu, 27 Jan 2022 11:30:42 +0000 (12:30 +0100)
Rearranged tests now measure raw latency without counting message
wrangling overhead.

Change-Id: Ic8b9b48495d5842beee3781d462ec45564af41a5

benchmark/gdbus.c
benchmark/p2p-gdbus.c

index eab04209b6af9a1b8f1b2fe065f1ad440996a213..75dc701a3885dc74a02f458e1194dc101d5b3c9d 100644 (file)
@@ -65,43 +65,22 @@ static void handle_method_call (GDBusConnection       *connection,
        unsigned long long end;
        unsigned long long temp;
        struct timespec clock;
+       double lt = 0;
        State *state = (State *)user_data;
 
        if (g_strcmp0 (method_name, "Perf") == 0)
        {
-               if(state->is_lt)
-                       g_variant_get (parameters, "(ts)", &start, &state->buf);
-               else
-                       g_variant_get (parameters, "(ts)", &temp, &state->buf);
-
-               g_object_unref (invocation);
-
-               if(++cnt == state->iters) {cnt = 0; g_main_loop_quit (state->main_loop); }
-
-               if(state->buf[0] != 'r')
-                       return;
-
                if(state->is_lt) {
                        clock_gettime (CLOCK_REALTIME, &clock);
                        end = (unsigned long long)clock.tv_sec * NS
                                +(unsigned long long)clock.tv_nsec;
 
-                       double lt = (double)(end - start) / 1000;
+                       g_variant_get(parameters, "(ts)", &start, &state->buf);
+
+                       lt = (double)(end - start) / 1000;
 #ifdef DEBUG_ON
                        printf("latency: %0.4f\n", lt);
 #endif
-                       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;
-                       }
                }
                else {
                        bw_cnt++;
@@ -118,6 +97,30 @@ static void handle_method_call (GDBusConnection       *connection,
                                bw = ((unsigned long long)NS * bw_cnt)/(end - start);
                                printf("bandwidth: %llu (/s)\n", bw);
                        }
+
+                       g_variant_get (parameters, "(ts)", &temp, &state->buf);
+               }
+
+               g_object_unref (invocation);
+
+               if(++cnt == state->iters) {cnt = 0; g_main_loop_quit (state->main_loop); }
+
+               if(state->buf[0] != 'r')
+                       return;
+
+               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;
+                       }
                }
        }
 }
index 779e44d2f93403558e6015e219a0520e746f82fc..01d28edc56c4f29a3269ec1ebc4ddb366bcc019e 100644 (file)
@@ -56,15 +56,33 @@ static void handle_method_call(GDBusConnection *connection,
        static unsigned long long start;
        unsigned long long end;
        unsigned long long temp;
+       double lt = 0;
        State *state = (State *)user_data;
 
        if (g_strcmp0(method_name, "Perf") != 0)
                return;
 
-       if (state->is_lt)
+       if (state->is_lt) {             /* we're measuring latency */
+               end = get_current_time();
                g_variant_get(parameters, "(ts)", &start, &state->buf);
-       else
+               lt = (double)(end - start) / 1000;
+       }
+       else {                          /* we're measuring bandwidth */
+               bw_cnt++;
+               if (state->verbose)
+                       printf("-> bw_cnt = %d (from: %s)\n", bw_cnt, interface_name);
+               if (bw_cnt == 1) {
+                       start = get_current_time();
+               }
+
+               if (bw_cnt == n_real_tries) {
+                       end = get_current_time();
+                       bw = ((unsigned long long)NS * bw_cnt)/(end - start);
+                       printf("bandwidth: %llu (/s)\n", bw);
+               }
+
                g_variant_get (parameters, "(ts)", &temp, &state->buf);
+       }
 
        g_object_unref(invocation);
 
@@ -76,9 +94,7 @@ static void handle_method_call(GDBusConnection *connection,
        if (state->buf[0] != 'R')       /* skip warm-up tries */
                return;
 
-       if (state->is_lt) {             /* we're measuring latency */
-               end = get_current_time();
-               double lt = (double)(end - start) / 1000;
+       if (state->is_lt) {
                if (state->verbose)
                        g_print("latency: %0.4f\n", lt);
                if (raw_data_on)
@@ -92,20 +108,6 @@ static void handle_method_call(GDBusConnection *connection,
                                min = lt;
                }
        }
-       else {                          /* we're measuring bandwidth */
-               bw_cnt++;
-               if (state->verbose)
-                       printf("-> bw_cnt = %d (from: %s)\n", bw_cnt, interface_name);
-               if (bw_cnt == 1) {
-                       start = get_current_time();
-               }
-
-               if (bw_cnt == n_real_tries) {
-                       end = get_current_time();
-                       bw = ((unsigned long long)NS * bw_cnt)/(end - start);
-                       printf("bandwidth: %llu (/s)\n", bw);
-               }
-       }
 
        if (state->verbose) {
                unsigned long long ts = (state->is_lt ? start : temp);