From: Adam Michalski Date: Thu, 27 Jan 2022 11:30:42 +0000 (+0100) Subject: Rearrange gdbus and peer to peer gdbus tests X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7905c29b8842bb340d8071e619734058b3d90674;p=platform%2Fcore%2Fsystem%2Fdbus-tools.git Rearrange gdbus and peer to peer gdbus tests Rearranged tests now measure raw latency without counting message wrangling overhead. Change-Id: Ic8b9b48495d5842beee3781d462ec45564af41a5 --- diff --git a/benchmark/gdbus.c b/benchmark/gdbus.c index eab0420..75dc701 100644 --- a/benchmark/gdbus.c +++ b/benchmark/gdbus.c @@ -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; + } } } } diff --git a/benchmark/p2p-gdbus.c b/benchmark/p2p-gdbus.c index 779e44d..01d28ed 100644 --- a/benchmark/p2p-gdbus.c +++ b/benchmark/p2p-gdbus.c @@ -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);