]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Small changes in pinpong test
authorMartin Molnar <molnam1@fel.cvut.cz>
Tue, 17 Mar 2009 20:15:02 +0000 (21:15 +0100)
committerMartin <molnam1@fel.cvut.cz>
Tue, 17 Mar 2009 20:15:02 +0000 (21:15 +0100)
frsh_api/tests/pingpong/ping.c
frsh_api/tests/pingpong/pong.c
frsh_api/tests/pingpong/test_config.h

index 8c6a973cddf7205db5136922525c842bc6f5e79e..9d5e75807165a3976a2fcdd4701167ea72dbb193 100644 (file)
@@ -24,9 +24,9 @@ int exit_flag = 0;
 int node_id = 0;
 
 /** statistics */
-long int max = 0; /* maximum delay */
-long int min = 0; /* minimum delay */
-long int avg = 0; /* average delay */
+long unsigned int max = 0; /* maximum delay */
+long unsigned int min = ~0; /* minimum delay */
+long unsigned int avg = 0; /* average delay */
 
 
 inline void timespec_sub(struct timespec *diff, const struct timespec *left,
@@ -83,7 +83,7 @@ void* sender(void * arg)
        sleep(2);
        //fwp_set_rt_prio(90);
        
-       count = 1;
+       count = 0;
        while (count != num_msg) {
                count++;
                clock_gettime(CLOCK_MONOTONIC, &sendtime);
@@ -139,6 +139,7 @@ void* receiver()
                timespec_sub(&difftime, &recvtime, &sendtime);
                tmp =  difftime.tv_sec * 1000 + 
                                difftime.tv_nsec / 1000000;
+       
                if (tmp > max) 
                        max = tmp;
                if (tmp < min) 
@@ -150,6 +151,8 @@ void* receiver()
 
        printf("Min= %ld ms Max = %ld ms Avg = %ld ms\n", min, max, avg/count);
        /* TODO: destroy vres and send enpoint */
+       
+       exit_flag = 0;
 
        return NULL;
 }
index 7b0ea73036ed2a7f28e5cdb3488365b50dca57b3..ae52a764cbf7214c04d29fbc7c69bb6d3b0ba70b 100644 (file)
@@ -19,6 +19,11 @@ size_t msg_size = MSGBUFFSIZE;
 frsh_send_endpoint_t sepoint;
 frsh_vres_id_t vres;
 
+/** statistics */
+long unsigned int max = 0; /* maximum delay */
+long unsigned int min = ~0; /* minimum delay */
+long unsigned int avg = 0; /* average delay */
+
 inline void timespec_sub(struct timespec *diff, const struct timespec *left,
              const struct timespec *right)
 {
@@ -83,6 +88,7 @@ void* receiver()
        struct timespec recvtime;
        struct timespec sendtime;
        struct timespec difftime;
+       long int tmp;
        
        recv_pinfo.body = NULL;
        /* local_addr should be handled when creating socket */
@@ -92,7 +98,7 @@ void* receiver()
        }
        printf("Receive endpoint created\n");
        
-       count = 1;
+       count = 0;
        while (count != num_msg){
                count++;
                if ((frsh_receive_sync(repoint, msg, msg_size, &len, 
@@ -115,8 +121,19 @@ void* receiver()
                timespec_sub(&difftime, &recvtime, &sendtime);  
                printf("Pong: Received - %s\n time= %ld us\n", msg, 
                                difftime.tv_nsec / 1000);
+               
+               tmp =  difftime.tv_sec * 1000 + 
+                               difftime.tv_nsec / 1000000;
+       
+               if (tmp > max) 
+                       max = tmp;
+               if (tmp < min) 
+                       min = tmp;
+               avg += tmp;
        }
        
+       printf("Min= %ld ms Max = %ld ms Avg = %ld ms\n", min, max, avg/count);
+       sleep(3); /* wait to send back packet */
        /* TODO: destroy vres and send enpoint */
 
        return NULL;
index 46376d076446313f1b3f41fa80c978132e062779..e6751ceb8373a039b4e199ec79b8b92f5cbfc436 100644 (file)
@@ -18,6 +18,6 @@
 /* Number of test messages sent/received
  * 0 - infinite
  */
-#define TEST_NUM_MSG 4
+#define TEST_NUM_MSG 3
 
 #endif /* TEST_CONFIG_H */