Add a busy-wait option [-w] to libdbus daemon test 62/268362/4
authorMichal Bloch <m.bloch@samsung.com>
Tue, 8 Mar 2022 14:45:15 +0000 (15:45 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Tue, 8 Mar 2022 14:45:28 +0000 (15:45 +0100)
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 <m.bloch@samsung.com>
benchmark/libdbus.c

index 57dcbec617895b62c6793cf39a5b067dd833ef86..a5d645b985eaa126c35fa9c3eee5547fbee5cf09 100644 (file)
@@ -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);
        }