From ce562805f454c993eedeb3ec1a572d1dc84992d4 Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Tue, 8 Mar 2022 15:45:15 +0100 Subject: [PATCH] Add a busy-wait option [-w] to libdbus daemon test Makes the test more consistent by avoiding scheduler and memory cache issues, leaving just true latency (-60% to values on my particular setup). However, also makes it model the real world less well. This makes it good for %-based comparisons, but less so for absolute time measurements. Change-Id: Ia71976c83e26f180babfe7f512adebda20e281e6 Signed-off-by: Michal Bloch --- benchmark/libdbus.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/benchmark/libdbus.c b/benchmark/libdbus.c index 57dcbec..a5d645b 100644 --- a/benchmark/libdbus.c +++ b/benchmark/libdbus.c @@ -20,6 +20,7 @@ double min, max, total; unsigned long long bw; bool lt_on, bw_on; +bool busy_wait; bool stop; bool raw_data_on; /* dump raw data (every possible result) */ @@ -131,7 +132,7 @@ void Receive(register int size, const char *name, const char *path, bool is_lt) //for(int i = 0; i < WARMUP_TRY + n_real_tries; i++) { while(1) { - if(!dbus_connection_read_write_dispatch(conn, -1)) { + if(!dbus_connection_read_write_dispatch(conn, busy_wait ? 0 : -1)) { printf("read on parent error\n"); exit(1); } @@ -372,6 +373,12 @@ void Measure_latency(void) } } +void print_help_libdbus(char **argv) +{ + print_help(argv); + printf("-w: do busy-waiting on messages\n"); +} + int main(int argc, char **argv) { @@ -386,7 +393,7 @@ main(int argc, char **argv) n_real_tries = REAL_TRY; msize = 3; lt_on = bw_on = false; - while((opt = getopt(argc, argv, "m:p:blhrt:")) != -1) { + while((opt = getopt(argc, argv, "m:p:blwhrt:")) != -1) { switch(opt) { case 'm': msize = atoi(optarg); @@ -408,6 +415,9 @@ main(int argc, char **argv) case 'l': lt_on = true; break; + case 'w': + busy_wait = true; + break; case 't': n_real_tries = atoi(optarg); if (n_real_tries <= 0) { @@ -419,13 +429,13 @@ main(int argc, char **argv) raw_data_on = true; /* dump raw data */ break; case 'h': - print_help(argv); + print_help_libdbus(argv); exit(0); } } if(!lt_on && !bw_on) { - print_help(argv); + print_help_libdbus(argv); exit(0); } -- 2.34.1