Add real tries parameterization 38/268838/4
authorAdam Michalski <a.michalski2@partner.samsung.com>
Mon, 3 Jan 2022 14:10:31 +0000 (15:10 +0100)
committerAdam Michalski <a.michalski2@partner.samsung.com>
Tue, 4 Jan 2022 11:43:10 +0000 (12:43 +0100)
Let the user specify the number of real tries in each of the IPC tests.
Take the default number of real tries as 1000, as it was previously
hard-coded.

Change-Id: I016e1f38479ecf4a81ed72a38900e51ccae54231

benchmark/gdbus.c
benchmark/libdbus.c
benchmark/p2p-gdbus.c
benchmark/pipe.c
benchmark/sharedmem.c
benchmark/socket.c

index c4df6ab049f82c03b9d5fe3056f6bc4ee351e5a4..eab04209b6af9a1b8f1b2fe065f1ad440996a213 100644 (file)
@@ -15,6 +15,7 @@ typedef struct _state {
 
 int nprocs;
 int msize;
+int n_real_tries;
 int lt_cnt;
 double min, max, total;
 unsigned long long bw;
@@ -110,7 +111,7 @@ static void handle_method_call (GDBusConnection       *connection,
                                        + (unsigned long long)clock.tv_nsec;
                        }
 
-                       if(bw_cnt == REAL_TRY) {
+                       if(bw_cnt == n_real_tries) {
                                clock_gettime (CLOCK_REALTIME, &clock);
                                end = (unsigned long long)clock.tv_sec * NS
                                        +(unsigned long long)clock.tv_nsec;
@@ -157,7 +158,7 @@ void Receive(register int size, const char *name, const char *path, bool is_lt)
        GDBusNodeInfo *introspection_data = NULL;
        introspection_data = g_dbus_node_info_new_for_xml (_interface_introspection_xml, NULL);
 
-       state.iters = WARMUP_TRY + REAL_TRY;
+       state.iters = WARMUP_TRY + n_real_tries;
        state.is_lt = is_lt;
        state.buf = buf;
        state.main_loop = g_main_loop;
@@ -187,7 +188,7 @@ void Send(register int size, const char *name, const char *path, bool is_lt)
        g_assert(conn != NULL);
 
        sleep(2);
-       for(int i = 0; i < WARMUP_TRY + REAL_TRY; i++) {
+       for(int i = 0; i < WARMUP_TRY + n_real_tries; i++) {
                struct timespec clock;
 
                memset(cptr, 0, size);
@@ -415,9 +416,10 @@ main(int argc, char **argv)
        if(nprocs == 1)
                nprocs = 2;
 
+       n_real_tries = REAL_TRY;
        msize = 3;
        lt_on = bw_on = false;
-       while((opt = getopt(argc, argv, "m:p:blhr")) != -1) {
+       while((opt = getopt(argc, argv, "m:p:blhrt:")) != -1) {
                switch(opt) {
                case 'm':
                        msize = atoi(optarg);
@@ -439,6 +441,13 @@ main(int argc, char **argv)
                case 'l':
                        lt_on = true;
                        break;
+               case 't':
+                       n_real_tries = atoi(optarg);
+                       if (n_real_tries <= 0) {
+                               printf("Number of real tries must be larger than 0\n");
+                               exit(0);
+                       }
+                       break;
                case 'r':
                        raw_data_on = true;     /* dump raw data */
                        break;
index de38164eb1768239ca3f23e9d711782f5ea1cc25..c13cf3ab6782930935929868a9f1321e840ddaa4 100644 (file)
@@ -14,6 +14,7 @@ typedef struct _state {
 
 int nprocs;
 int msize;
+int n_real_tries;
 int lt_cnt;
 double min, max, total;
 unsigned long long bw;
@@ -72,7 +73,7 @@ static DBusHandlerResult message_func (DBusConnection *connection,
                                        + (unsigned long long)clock.tv_nsec;
                        }
 
-                       if(bw_cnt == REAL_TRY) {
+                       if(bw_cnt == n_real_tries) {
                                clock_gettime (CLOCK_REALTIME, &clock);
                                end = (unsigned long long)clock.tv_sec * NS
                                        +(unsigned long long)clock.tv_nsec;
@@ -120,12 +121,12 @@ void Receive(register int size, const char *name, const char *path, bool is_lt)
                exit(1);
        }
 
-       state.iters = WARMUP_TRY + REAL_TRY;
+       state.iters = WARMUP_TRY + n_real_tries;
        state.is_lt = is_lt;
        state.buf = buf;
        dbus_connection_register_object_path (conn, path, &vtable, &state);
 
-       //for(int i = 0; i < WARMUP_TRY + REAL_TRY; i++) {
+       //for(int i = 0; i < WARMUP_TRY + n_real_tries; i++) {
        while(1) {
                if(!dbus_connection_read_write_dispatch(conn, -1)) {
                        printf("read on parent error\n");
@@ -156,7 +157,7 @@ void Send(register int size, const char *name, const char *path, const char *cli
        }
 
        sleep(2);
-       for(int i = 0; i < WARMUP_TRY + REAL_TRY; i++) {
+       for(int i = 0; i < WARMUP_TRY + n_real_tries; i++) {
                struct timespec clock;
 
                memset(cptr, 0, size);
@@ -380,9 +381,10 @@ main(int argc, char **argv)
        if(nprocs == 1)
                nprocs = 2;
 
+       n_real_tries = REAL_TRY;
        msize = 3;
        lt_on = bw_on = false;
-       while((opt = getopt(argc, argv, "m:p:blhr")) != -1) {
+       while((opt = getopt(argc, argv, "m:p:blhrt:")) != -1) {
                switch(opt) {
                case 'm':
                        msize = atoi(optarg);
@@ -390,7 +392,7 @@ main(int argc, char **argv)
                case 'p':
                        nprocs = atoi(optarg);
                        if(nprocs <= 0) {
-                               printf("The number of process should be larger than 0\n");
+                               printf("The number of process must be larger than 0\n");
                                exit(0);
                        }
                        if(nprocs % 2 != 0) {
@@ -404,6 +406,13 @@ main(int argc, char **argv)
                case 'l':
                        lt_on = true;
                        break;
+               case 't':
+                       n_real_tries = atoi(optarg);
+                       if (n_real_tries <= 0) {
+                               printf("Number of real tries should be larger than 0\n");
+                               exit(0);
+                       }
+                       break;
                case 'r':
                        raw_data_on = true;     /* dump raw data */
                        break;
index fb63e8c78108bcd29b1488c7704cf68fbfb40699..7f4888e0847050930cf7b92a5e7b96170ff64fcd 100644 (file)
@@ -610,7 +610,7 @@ int main(int argc, char *argv[])
                case 't':
                        n_real_tries = atoi(optarg);
                        if (n_real_tries <= 0) {
-                               printf("Number of real tries should be larger than 0\n");
+                               printf("Number of real tries must be larger than 0\n");
                                exit(0);
                        }
                        break;
index 0b649cb2359e2973ad129267ba8fc10652215566..be7bb9184adb600c8931733766574682b7369d81 100644 (file)
@@ -7,6 +7,7 @@
 
 int nprocs;
 int msize;
+int n_real_tries;
 int lt_cnt;
 double min, max, total;
 unsigned long long bw;
@@ -23,7 +24,7 @@ void Receive(int rfd1, int rfd2, register int size, bool is_lt)
        unsigned long long end;
        register char *buf = (char *)malloc(size);
 
-       for(int i = 0; i < WARMUP_TRY + REAL_TRY; i++) {
+       for(int i = 0; i < WARMUP_TRY + n_real_tries; i++) {
                if(is_lt) {
                        if (read(rfd1, (void *)&start, sizeof(unsigned long long))
                                != sizeof(unsigned long long)) {
@@ -67,7 +68,7 @@ void Receive(int rfd1, int rfd2, register int size, bool is_lt)
                                                + (unsigned long long)clock.tv_nsec;
                                }
 
-                               if(bw_cnt == REAL_TRY) {
+                               if(bw_cnt == n_real_tries) {
                                        clock_gettime (CLOCK_REALTIME, &clock);
                                        end = (unsigned long long)clock.tv_sec * NS
                                                +(unsigned long long)clock.tv_nsec;
@@ -86,7 +87,7 @@ void Send(int wfd1, int wfd2, register int size, bool is_lt)
        register char *cptr = (char *)malloc(size);
 
        sleep(2);
-       for(int i = 0; i < WARMUP_TRY + REAL_TRY; i++) {
+       for(int i = 0; i < WARMUP_TRY + n_real_tries; i++) {
                int wres1, wres2;
                struct timespec clock;
 
@@ -331,9 +332,10 @@ main(int argc, char **argv)
        if(nprocs == 1)
                nprocs = 2;
 
+       n_real_tries = REAL_TRY;
        msize = 3;
        lt_on = bw_on = false;
-       while((opt = getopt(argc, argv, "m:p:blhr")) != -1) {
+       while((opt = getopt(argc, argv, "m:p:blhrt:")) != -1) {
                switch(opt) {
                case 'm':
                        msize = atoi(optarg);
@@ -355,6 +357,13 @@ main(int argc, char **argv)
                case 'l':
                        lt_on = true;
                        break;
+               case 't':
+                       n_real_tries = atoi(optarg);
+                       if (n_real_tries <= 0) {
+                               printf("Number of real tries must be larger than 0\n");
+                               exit(0);
+                       }
+                       break;
                case 'r':
                        raw_data_on = true;     /* dump raw data */
                        break;
index ccfe4cc9ad055af28a6c20b40d9d4e8d26ec2695..fe4ba9891572430bb0df6dda35aa21aec40840d6 100644 (file)
@@ -13,6 +13,7 @@ const char *shm_name2 = "sharedmem2";
 
 int nprocs;
 int msize;
+int n_real_tries;
 int lt_cnt;
 double min, max, total;
 unsigned long long bw;
@@ -31,7 +32,7 @@ void Receive(void *r1, register char *r2, register int size, bool is_lt)
        register char read_cnt = 0;
        register char *buf = (char *)malloc(size);
 
-       for(int i = 0; i < WARMUP_TRY + REAL_TRY; i++) {
+       for(int i = 0; i < WARMUP_TRY + n_real_tries; i++) {
 repeat:
                if(r2[1] == read_cnt)
                        goto repeat;
@@ -73,7 +74,7 @@ repeat:
                                        + (unsigned long long)clock.tv_nsec;
                        }
 
-                       if(bw_cnt == REAL_TRY) {
+                       if(bw_cnt == n_real_tries) {
                                clock_gettime (CLOCK_REALTIME, &clock);
                                end = (unsigned long long)clock.tv_sec * NS
                                        +(unsigned long long)clock.tv_nsec;
@@ -93,7 +94,7 @@ void Send(void *w1, register char *w2, register int size, bool is_lt)
        register char *cptr = (char *)malloc(size);
 
        sleep(2);
-       for(int i = 0; i < WARMUP_TRY + REAL_TRY; i++) {
+       for(int i = 0; i < WARMUP_TRY + n_real_tries; i++) {
                struct timespec clock;
 repeat:
                if(w2[2] == write_cnt) {
@@ -422,9 +423,10 @@ main(int argc, char **argv)
        if(nprocs == 1)
                nprocs = 2;
 
+       n_real_tries = REAL_TRY;
        msize = 3;
        lt_on = bw_on = false;
-       while((opt = getopt(argc, argv, "m:p:blrh")) != -1) {
+       while((opt = getopt(argc, argv, "m:p:blrht:")) != -1) {
                switch(opt) {
                case 'm':
                        msize = atoi(optarg);
@@ -446,6 +448,13 @@ main(int argc, char **argv)
                case 'l':
                        lt_on = true;
                        break;
+               case 't':
+                       n_real_tries = atoi(optarg);
+                       if (n_real_tries <= 0) {
+                               printf("Number of real tries must be larger than 0\n");
+                               exit(0);
+                       }
+                       break;
                case 'r':
                        raw_data_on = true;     /* dump raw data */
                        break;
index 7541689bd4b9bb3861699aca61accd8f8f82f6fc..b3f17edbdf0d5809e67b1af0d485874e033de708 100644 (file)
@@ -7,6 +7,7 @@
 
 int nprocs;
 int msize;
+int n_real_tries;
 int lt_cnt;
 double min, max, total;
 unsigned long long bw;
@@ -23,7 +24,7 @@ void Receive(int rfd1, int rfd2, register int size, bool is_lt)
        unsigned long long end;
        register char *buf = (char *)malloc(size);
 
-       for(int i = 0; i < WARMUP_TRY + REAL_TRY; i++) {
+       for(int i = 0; i < WARMUP_TRY + n_real_tries; i++) {
                if(is_lt) {
                        if (read(rfd1, (void *)&start, sizeof(unsigned long long))
                                != sizeof(unsigned long long)) {
@@ -67,7 +68,7 @@ void Receive(int rfd1, int rfd2, register int size, bool is_lt)
                                                + (unsigned long long)clock.tv_nsec;
                                }
 
-                               if(bw_cnt == REAL_TRY) {
+                               if(bw_cnt == n_real_tries) {
                                        clock_gettime (CLOCK_REALTIME, &clock);
                                        end = (unsigned long long)clock.tv_sec * NS
                                                +(unsigned long long)clock.tv_nsec;
@@ -86,7 +87,7 @@ void Send(int wfd1, int wfd2, register int size, bool is_lt)
        register char *cptr = (char *)malloc(size);
 
        sleep(2);
-       for(int i = 0; i < WARMUP_TRY + REAL_TRY; i++) {
+       for(int i = 0; i < WARMUP_TRY + n_real_tries; i++) {
                int wres1, wres2;
                struct timespec clock;
 
@@ -328,9 +329,10 @@ main(int argc, char **argv)
        if(nprocs == 1)
                nprocs = 2;
 
+       n_real_tries = REAL_TRY;
        msize = 3;
        lt_on = bw_on = false;
-       while((opt = getopt(argc, argv, "m:p:blrh")) != -1) {
+       while((opt = getopt(argc, argv, "m:p:blrht:")) != -1) {
                switch(opt) {
                case 'm':
                        msize = atoi(optarg);
@@ -352,6 +354,13 @@ main(int argc, char **argv)
                case 'l':
                        lt_on = true;
                        break;
+               case 't':
+                       n_real_tries = atoi(optarg);
+                       if (n_real_tries <= 0) {
+                               printf("Number of real tries must be larger than 0\n");
+                               exit(0);
+                       }
+                       break;
                case 'r':
                        raw_data_on = true;     /* dump raw data */
                        break;