aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testbed/testbed_api_testbed.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index 73a4bcfdd..a03c23d15 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -280,6 +280,23 @@ struct RunContext
280 280
281 281
282/** 282/**
283 * Function to return the string representation of the duration between current
284 * time and `pstart_time' in `RunContext'
285 *
286 * @param rc the RunContext
287 * @return the representation string; this is NOT reentrant
288 */
289static const char *
290prof_time (struct RunContext *rc)
291{
292 struct GNUNET_TIME_Relative ptime;
293
294 ptime = GNUNET_TIME_absolute_get_duration (rc->pstart_time);
295 return GNUNET_STRINGS_relative_time_to_string (ptime, GNUNET_YES);
296}
297
298
299/**
283 * Task for starting peers 300 * Task for starting peers
284 * 301 *
285 * @param cls the RunHandle 302 * @param cls the RunHandle
@@ -319,7 +336,6 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
319{ 336{
320 struct DLLOperation *dll_op = cls; 337 struct DLLOperation *dll_op = cls;
321 struct RunContext *rc; 338 struct RunContext *rc;
322 struct GNUNET_TIME_Relative ptime;
323 339
324 GNUNET_assert (NULL != dll_op); 340 GNUNET_assert (NULL != dll_op);
325 rc = dll_op->rc; 341 rc = dll_op->rc;
@@ -339,9 +355,7 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
339 rc->peer_count++; 355 rc->peer_count++;
340 if (rc->peer_count < rc->num_peers) 356 if (rc->peer_count < rc->num_peers)
341 return; 357 return;
342 ptime = GNUNET_TIME_absolute_get_duration (rc->pstart_time); 358 DEBUG ("%u peers created in %s\n", rc->num_peers, prof_time (rc));
343 DEBUG ("%u peers created in %s\n", rc->num_peers,
344 GNUNET_STRINGS_relative_time_to_string (ptime, GNUNET_YES));
345 GNUNET_SCHEDULER_add_now (&start_peers_task, rc); 359 GNUNET_SCHEDULER_add_now (&start_peers_task, rc);
346} 360}
347 361
@@ -490,9 +504,15 @@ shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
490 dll_op); 504 dll_op);
491 } 505 }
492 if (all_peers_destroyed == GNUNET_NO) 506 if (all_peers_destroyed == GNUNET_NO)
507 {
508 DEBUG ("Destroying peers\n");
509 rc->pstart_time = GNUNET_TIME_absolute_get ();
493 return; 510 return;
511 }
494 } 512 }
495 /* Some peers are stopped */ 513 /* Some peers are stopped */
514 DEBUG ("Stopping peers\n");
515 rc->pstart_time = GNUNET_TIME_absolute_get ();
496 for (peer = 0; peer < rc->num_peers; peer++) 516 for (peer = 0; peer < rc->num_peers; peer++)
497 { 517 {
498 if ((NULL == rc->peers[peer]) || (PS_STARTED != rc->peers[peer]->state)) 518 if ((NULL == rc->peers[peer]) || (PS_STARTED != rc->peers[peer]->state))
@@ -500,7 +520,6 @@ shutdown_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
500 rc->peer_count++; 520 rc->peer_count++;
501 continue; 521 continue;
502 } 522 }
503 DEBUG ("Stopping peer %u\n", peer);
504 dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); 523 dll_op = GNUNET_malloc (sizeof (struct DLLOperation));
505 dll_op->op = GNUNET_TESTBED_peer_stop (rc->peers[peer], NULL, NULL); 524 dll_op->op = GNUNET_TESTBED_peer_stop (rc->peers[peer], NULL, NULL);
506 dll_op->cls = rc->peers[peer]; 525 dll_op->cls = rc->peers[peer];
@@ -659,6 +678,9 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
659 case RC_LINKED: 678 case RC_LINKED:
660 case RC_READY: 679 case RC_READY:
661 rc->state = RC_PEERS_STOPPED; 680 rc->state = RC_PEERS_STOPPED;
681 DEBUG ("Peers stopped in %s\n", prof_time (rc));
682 DEBUG ("Destroying peers\n");
683 rc->pstart_time = GNUNET_TIME_absolute_get ();
662 rc->peer_count = 0; 684 rc->peer_count = 0;
663 for (peer_id = 0; peer_id < rc->num_peers; peer_id++) 685 for (peer_id = 0; peer_id < rc->num_peers; peer_id++)
664 { 686 {
@@ -672,7 +694,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
672 rc->state = RC_PEERS_DESTROYED; 694 rc->state = RC_PEERS_DESTROYED;
673 GNUNET_free (rc->peers); 695 GNUNET_free (rc->peers);
674 rc->peers = NULL; 696 rc->peers = NULL;
675 DEBUG ("All peers successfully destroyed\n"); 697 DEBUG ("Peers destroyed in %s\n", prof_time (rc));
676 GNUNET_SCHEDULER_add_now (&cleanup_task, rc); 698 GNUNET_SCHEDULER_add_now (&cleanup_task, rc);
677 break; 699 break;
678 default: 700 default:
@@ -698,9 +720,7 @@ call_cc:
698 if (rc->peer_count < rc->num_peers) 720 if (rc->peer_count < rc->num_peers)
699 return; 721 return;
700 DEBUG ("%u peers started in %s\n", rc->num_peers, 722 DEBUG ("%u peers started in %s\n", rc->num_peers,
701 GNUNET_STRINGS_relative_time_to_string 723 prof_time (rc));
702 (GNUNET_TIME_absolute_get_duration(rc->pstart_time),
703 GNUNET_YES));
704 if (GNUNET_TESTBED_TOPOLOGY_NONE != rc->topology) 724 if (GNUNET_TESTBED_TOPOLOGY_NONE != rc->topology)
705 { 725 {
706 if ( (GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI == rc->topology) 726 if ( (GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI == rc->topology)