- start test only after warmup
authorBart Polot <bart@net.in.tum.de>
Sat, 22 Mar 2014 02:58:22 +0000 (02:58 +0000)
committerBart Polot <bart@net.in.tum.de>
Sat, 22 Mar 2014 02:58:22 +0000 (02:58 +0000)
src/mesh/gnunet-mesh-profiler.c

index dbbff157b1f054d84b0ff2096090230ead0f9d22..9545e347c2195d6215726d89b459f2a0b37df092 100644 (file)
@@ -232,6 +232,11 @@ static unsigned int current_round;
  */
 static int do_warmup;
 
+/**
+ * Warmup progress.
+ */
+static unsigned int peers_warmup;
+
 /**
  * Flag to notify callbacks not to generate any new traffic anymore.
  */
@@ -776,6 +781,11 @@ incoming_channel (void *cls, struct GNUNET_MESH_Channel *channel,
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO, "WARMUP %u <= %u\n",
                 n, get_index (peer), channel);
+    peers_warmup++;
+    if (peers_warmup < peers_total)
+      return NULL;
+    test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                              &start_test, NULL);
     return NULL;
   }
   GNUNET_assert (peer == peers[n].incoming);
@@ -923,7 +933,6 @@ peer_id_cb (void *cls,
        const char *emsg)
 {
   long n = (long) cls;
-  struct GNUNET_TIME_Relative delay;
 
   if (NULL == pinfo || NULL != emsg)
   {
@@ -946,10 +955,12 @@ peer_id_cb (void *cls,
     return;
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got all IDs, starting profiler\n");
   if (do_warmup)
+  {
     warmup();
-  delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
-                                         150 * peers_total);
-  test_task = GNUNET_SCHEDULER_add_delayed (delay, &start_test, NULL);
+    return; /* start_test from incoming_channel */
+  }
+  test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                            &start_test, NULL);
 }
 
 /**