gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r25864 - gnunet/src/testbed


From: gnunet
Subject: [GNUnet-SVN] r25864 - gnunet/src/testbed
Date: Wed, 23 Jan 2013 15:40:42 +0100

Author: harsha
Date: 2013-01-23 15:40:42 +0100 (Wed, 23 Jan 2013)
New Revision: 25864

Modified:
   gnunet/src/testbed/testbed_api_testbed.c
Log:
- print time durations in debug output

Modified: gnunet/src/testbed/testbed_api_testbed.c
===================================================================
--- gnunet/src/testbed/testbed_api_testbed.c    2013-01-23 13:28:10 UTC (rev 
25863)
+++ gnunet/src/testbed/testbed_api_testbed.c    2013-01-23 14:40:42 UTC (rev 
25864)
@@ -280,6 +280,23 @@
 
 
 /**
+ * Function to return the string representation of the duration between current
+ * time and `pstart_time' in `RunContext'
+ *
+ * @param rc the RunContext
+ * @return the representation string; this is NOT reentrant
+ */
+static const char *
+prof_time (struct RunContext *rc)
+{
+  struct GNUNET_TIME_Relative ptime;
+
+  ptime = GNUNET_TIME_absolute_get_duration (rc->pstart_time);
+  return GNUNET_STRINGS_relative_time_to_string (ptime, GNUNET_YES);
+}
+
+
+/**
  * Task for starting peers
  *
  * @param cls the RunHandle
@@ -319,7 +336,6 @@
 {
   struct DLLOperation *dll_op = cls;
   struct RunContext *rc;
-  struct GNUNET_TIME_Relative ptime;
 
   GNUNET_assert (NULL != dll_op);
   rc = dll_op->rc;
@@ -339,9 +355,7 @@
   rc->peer_count++;
   if (rc->peer_count < rc->num_peers)
     return;
-  ptime = GNUNET_TIME_absolute_get_duration (rc->pstart_time);
-  DEBUG ("%u peers created in %s\n", rc->num_peers,
-         GNUNET_STRINGS_relative_time_to_string (ptime, GNUNET_YES));
+  DEBUG ("%u peers created in %s\n", rc->num_peers, prof_time (rc));
   GNUNET_SCHEDULER_add_now (&start_peers_task, rc);
 }
 
@@ -490,9 +504,15 @@
                                             dll_op);
         }
         if (all_peers_destroyed == GNUNET_NO)
+        {
+          DEBUG ("Destroying peers\n");
+          rc->pstart_time = GNUNET_TIME_absolute_get ();
           return;
+        }
       }
       /* Some peers are stopped */
+      DEBUG ("Stopping peers\n");
+      rc->pstart_time = GNUNET_TIME_absolute_get ();
       for (peer = 0; peer < rc->num_peers; peer++)
       {
         if ((NULL == rc->peers[peer]) || (PS_STARTED != 
rc->peers[peer]->state))
@@ -500,7 +520,6 @@
           rc->peer_count++;
           continue;
         }
-        DEBUG ("Stopping peer %u\n", peer);
         dll_op = GNUNET_malloc (sizeof (struct DLLOperation));
         dll_op->op = GNUNET_TESTBED_peer_stop (rc->peers[peer], NULL, NULL);
         dll_op->cls = rc->peers[peer];
@@ -659,6 +678,9 @@
   case RC_LINKED:
   case RC_READY:
     rc->state = RC_PEERS_STOPPED;
+    DEBUG ("Peers stopped in %s\n", prof_time (rc));
+    DEBUG ("Destroying peers\n");
+    rc->pstart_time = GNUNET_TIME_absolute_get ();
     rc->peer_count = 0;
     for (peer_id = 0; peer_id < rc->num_peers; peer_id++)
     {
@@ -672,7 +694,7 @@
     rc->state = RC_PEERS_DESTROYED;
     GNUNET_free (rc->peers);
     rc->peers = NULL;
-    DEBUG ("All peers successfully destroyed\n");
+    DEBUG ("Peers destroyed in %s\n", prof_time (rc));
     GNUNET_SCHEDULER_add_now (&cleanup_task, rc);
     break;
   default:
@@ -698,9 +720,7 @@
   if (rc->peer_count < rc->num_peers)
     return;  
   DEBUG ("%u peers started in %s\n", rc->num_peers,
-         GNUNET_STRINGS_relative_time_to_string
-         (GNUNET_TIME_absolute_get_duration(rc->pstart_time),
-          GNUNET_YES));
+         prof_time (rc));
   if (GNUNET_TESTBED_TOPOLOGY_NONE != rc->topology)
   {
     if ( (GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI == rc->topology)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]