From 406f6b790cbc558d2ba6905c64a4ff8b90171daa Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 31 Mar 2011 16:27:25 +0000 Subject: latest changes --- src/transport/test_transport_ats.c | 95 ++++++++++++++++++++++++++++---------- 1 file changed, 71 insertions(+), 24 deletions(-) (limited to 'src/transport/test_transport_ats.c') diff --git a/src/transport/test_transport_ats.c b/src/transport/test_transport_ats.c index 2880da8e5..97b824249 100644 --- a/src/transport/test_transport_ats.c +++ b/src/transport/test_transport_ats.c @@ -31,7 +31,7 @@ #define MEASUREMENTS 5 #define DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) -#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) +#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) static int ok; @@ -51,16 +51,20 @@ struct GNUNET_TESTING_Daemon * master_deamon; struct GNUNET_STATISTICS_Handle * stats; -struct ATS_result +struct TEST_result { uint64_t timestamp; - int mechs; - int peers; - int solution; + uint64_t duration; + uint64_t mechs; + uint64_t peers; + uint64_t solution; }; -//static int index; -static struct ATS_result results[MEASUREMENTS]; +static int r_index; +//static int measurements; +static int peers; +static struct TEST_result results[MEASUREMENTS]; + /** * Check whether peers successfully shut down. @@ -95,47 +99,81 @@ static void shutdown_peers() GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); } +static void evaluate_measurements() +{ + int c; + char * output = NULL; + char * temp; + for (c=0; c= MEASUREMENTS) + { + evaluate_measurements(); + return GNUNET_NO; + } + results[r_index].timestamp = value; + } + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "[%i] ATS solution: %s %llu \n", r_index, name, value); } + if (0 == strcmp (name,"ATS solution")) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "ATS solution: %s %llu \n",name, value); + results[r_index].solution = value; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "[%i] ATS solution: %s %llu \n", r_index, name, value); } + if (0 == strcmp (name,"ATS peers")) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "ATS peers: %s %llu \n",name, value); + results[r_index].peers = value; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "[%i] ATS peers: %s %llu \n", r_index, name, value); } + if (0 == strcmp (name,"ATS mechanisms")) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "ATS mechanisms: %s %llu \n",name, value); + results[r_index].mechs = value; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS mechanisms: %s %llu \n", r_index, name, value); } + if (0 == strcmp (name,"ATS duration")) { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - "ATS duration: %s %llu \n",name, value); + results[r_index].duration = value; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "[%i] ATS duration: %s %llu \n", r_index, name, value); } } - return GNUNET_OK; } @@ -154,7 +192,7 @@ stats_get_task (void *cls, GNUNET_STATISTICS_get (stats, "transport", "ATS peers", TIMEOUT, NULL, &stats_cb, NULL); GNUNET_STATISTICS_get (stats, "transport", "ATS mechanisms", TIMEOUT, NULL, &stats_cb, NULL); - stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), &stats_get_task, NULL); + stats_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250), &stats_get_task, NULL); } void @@ -262,7 +300,7 @@ run (void *cls, #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %i peers.\n", NUM_PEERS); #endif - peers_left = NUM_PEERS; + peers_left = peers; pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ peers_left, /* Number of outstanding connections */ @@ -298,13 +336,22 @@ main (int argc, char *argv[]) { int ret; - GNUNET_log_setup ("test-testing-group", + GNUNET_log_setup ("test-transport-ats", #if VERBOSE "DEBUG", #else "WARNING", #endif NULL); + + peers = NUM_PEERS; + if (argc >= 2) + { + peers = atoi(argv[1]); + peers++; + if(peers <1) + peers = NUM_PEERS; + } ret = check (); /** * Still need to remove the base testing directory here, -- cgit v1.2.3