aboutsummaryrefslogtreecommitdiff
path: root/src/rps/gnunet-rps-profiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/gnunet-rps-profiler.c')
-rw-r--r--src/rps/gnunet-rps-profiler.c284
1 files changed, 199 insertions, 85 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 16f23e86c..49714872f 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -49,7 +49,11 @@ static unsigned bits_needed;
49/** 49/**
50 * How long do we run the test? 50 * How long do we run the test?
51 */ 51 */
52//#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 52static struct GNUNET_TIME_Relative duration;
53
54/**
55 * When do we do a hard shutdown?
56 */
53static struct GNUNET_TIME_Relative timeout; 57static struct GNUNET_TIME_Relative timeout;
54 58
55 59
@@ -446,6 +450,10 @@ struct RPSPeer
446 * @brief statistics values 450 * @brief statistics values
447 */ 451 */
448 uint64_t stats[STAT_TYPE_MAX]; 452 uint64_t stats[STAT_TYPE_MAX];
453 /**
454 * @brief Handle for the statistics get request
455 */
456 struct GNUNET_STATISTICS_GetHandle *h_stat_get[STAT_TYPE_MAX];
449}; 457};
450 458
451/** 459/**
@@ -489,15 +497,16 @@ static unsigned int view_sizes;
489static int ok; 497static int ok;
490 498
491/** 499/**
492 * Identifier for the churn task that runs periodically 500 * Identifier for the task that runs after the test to collect results
493 */ 501 */
494static struct GNUNET_SCHEDULER_Task *post_test_task; 502static struct GNUNET_SCHEDULER_Task *post_test_task;
495 503
496/** 504/**
497 * Identifier for the churn task that runs periodically 505 * Identifier for the shutdown task
498 */ 506 */
499static struct GNUNET_SCHEDULER_Task *shutdown_task; 507static struct GNUNET_SCHEDULER_Task *shutdown_task;
500 508
509
501/** 510/**
502 * Identifier for the churn task that runs periodically 511 * Identifier for the churn task that runs periodically
503 */ 512 */
@@ -874,6 +883,75 @@ static int check_statistics_collect_completed ()
874 return GNUNET_YES; 883 return GNUNET_YES;
875} 884}
876 885
886static void
887rps_disconnect_adapter (void *cls,
888 void *op_result);
889
890static void
891cancel_pending_req (struct PendingRequest *pending_req)
892{
893 struct RPSPeer *rps_peer;
894
895 rps_peer = pending_req->rps_peer;
896 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head,
897 rps_peer->pending_req_tail,
898 pending_req);
899 rps_peer->num_pending_reqs--;
900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
901 "Cancelling pending rps get request\n");
902 GNUNET_SCHEDULER_cancel (pending_req->request_task);
903 GNUNET_free (pending_req);
904}
905
906static void
907cancel_request (struct PendingReply *pending_rep)
908{
909 struct RPSPeer *rps_peer;
910
911 rps_peer = pending_rep->rps_peer;
912 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head,
913 rps_peer->pending_rep_tail,
914 pending_rep);
915 rps_peer->num_pending_reps--;
916 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
917 "Cancelling rps get reply\n");
918 GNUNET_RPS_request_cancel (pending_rep->req_handle);
919 GNUNET_free (pending_rep);
920}
921
922void
923clean_peer (unsigned peer_index)
924{
925 struct PendingRequest *pending_req;
926
927 while (NULL != (pending_req = rps_peers[peer_index].pending_req_head))
928 {
929 cancel_pending_req (pending_req);
930 }
931 pending_req = rps_peers[peer_index].pending_req_head;
932 rps_disconnect_adapter (&rps_peers[peer_index],
933 &rps_peers[peer_index].rps_handle);
934 for (unsigned stat_type = STAT_TYPE_ROUNDS;
935 stat_type < STAT_TYPE_MAX;
936 stat_type++)
937 {
938 if (NULL != rps_peers[peer_index].h_stat_get[stat_type])
939 {
940 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
941 "(%u) did not yet receive stat value for `%s'\n",
942 rps_peers[peer_index].index,
943 stat_type_2_str (stat_type));
944 GNUNET_STATISTICS_get_cancel (
945 rps_peers[peer_index].h_stat_get[stat_type]);
946 }
947 }
948 if (NULL != rps_peers[peer_index].op)
949 {
950 GNUNET_TESTBED_operation_done (rps_peers[peer_index].op);
951 rps_peers[peer_index].op = NULL;
952 }
953}
954
877/** 955/**
878 * Task run on timeout to shut everything down. 956 * Task run on timeout to shut everything down.
879 */ 957 */
@@ -881,35 +959,55 @@ static void
881shutdown_op (void *cls) 959shutdown_op (void *cls)
882{ 960{
883 unsigned int i; 961 unsigned int i;
962 struct OpListEntry *entry;
884 963
885 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 964 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
886 "Shutdown task scheduled, going down.\n"); 965 "Shutdown task scheduled, going down.\n");
887 in_shutdown = GNUNET_YES; 966 in_shutdown = GNUNET_YES;
967
968 if (NULL != shutdown_task)
969 {
970 GNUNET_SCHEDULER_cancel (shutdown_task);
971 shutdown_task = NULL;
972 }
888 if (NULL != post_test_task) 973 if (NULL != post_test_task)
889 { 974 {
890 GNUNET_SCHEDULER_cancel (post_test_task); 975 GNUNET_SCHEDULER_cancel (post_test_task);
976 post_test_task = NULL;
891 } 977 }
892 if (NULL != churn_task) 978 if (NULL != churn_task)
893 { 979 {
894 GNUNET_SCHEDULER_cancel (churn_task); 980 GNUNET_SCHEDULER_cancel (churn_task);
895 churn_task = NULL; 981 churn_task = NULL;
896 } 982 }
983 entry = oplist_head;
984 while (NULL != (entry = oplist_head))
985 {
986 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
987 "Operation still pending on shutdown (%u)\n",
988 entry->index);
989 GNUNET_TESTBED_operation_done (entry->op);
990 GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry);
991 GNUNET_free (entry);
992 }
897 for (i = 0; i < num_peers; i++) 993 for (i = 0; i < num_peers; i++)
898 { 994 {
899 if (NULL != rps_peers[i].rps_handle) 995 clean_peer (i);
900 {
901 GNUNET_RPS_disconnect (rps_peers[i].rps_handle);
902 }
903 if (NULL != rps_peers[i].op)
904 {
905 GNUNET_TESTBED_operation_done (rps_peers[i].op);
906 }
907 } 996 }
908} 997}
909 998
999static void
1000trigger_shutdown (void *cls)
1001{
1002 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1003 "Shutdown was triggerd by timeout, going down.\n");
1004 shutdown_task = NULL;
1005 GNUNET_SCHEDULER_shutdown ();
1006}
1007
910 1008
911/** 1009/**
912 * Task run on timeout to collect statistics and potentially shut down. 1010 * Task run after #duration to collect statistics and potentially shut down.
913 */ 1011 */
914static void 1012static void
915post_test_op (void *cls) 1013post_test_op (void *cls)
@@ -919,7 +1017,7 @@ post_test_op (void *cls)
919 post_test_task = NULL; 1017 post_test_task = NULL;
920 post_test = GNUNET_YES; 1018 post_test = GNUNET_YES;
921 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1019 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
922 "Post test task scheduled, going down.\n"); 1020 "Post test task scheduled.\n");
923 if (NULL != churn_task) 1021 if (NULL != churn_task)
924 { 1022 {
925 GNUNET_SCHEDULER_cancel (churn_task); 1023 GNUNET_SCHEDULER_cancel (churn_task);
@@ -943,7 +1041,7 @@ post_test_op (void *cls)
943 GNUNET_YES == check_statistics_collect_completed()) 1041 GNUNET_YES == check_statistics_collect_completed())
944 { 1042 {
945 GNUNET_SCHEDULER_cancel (shutdown_task); 1043 GNUNET_SCHEDULER_cancel (shutdown_task);
946 shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL); 1044 shutdown_task = NULL;
947 GNUNET_SCHEDULER_shutdown (); 1045 GNUNET_SCHEDULER_shutdown ();
948 } 1046 }
949} 1047}
@@ -1030,9 +1128,9 @@ info_cb (void *cb_cls,
1030 */ 1128 */
1031static void 1129static void
1032rps_connect_complete_cb (void *cls, 1130rps_connect_complete_cb (void *cls,
1033 struct GNUNET_TESTBED_Operation *op, 1131 struct GNUNET_TESTBED_Operation *op,
1034 void *ca_result, 1132 void *ca_result,
1035 const char *emsg) 1133 const char *emsg)
1036{ 1134{
1037 struct RPSPeer *rps_peer = cls; 1135 struct RPSPeer *rps_peer = cls;
1038 struct GNUNET_RPS_Handle *rps = ca_result; 1136 struct GNUNET_RPS_Handle *rps = ca_result;
@@ -1057,7 +1155,9 @@ rps_connect_complete_cb (void *cls,
1057 return; 1155 return;
1058 } 1156 }
1059 1157
1060 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started client successfully\n"); 1158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1159 "Started client successfully (%u)\n",
1160 rps_peer->index);
1061 1161
1062 cur_test_run.main_test (rps_peer); 1162 cur_test_run.main_test (rps_peer);
1063} 1163}
@@ -1075,7 +1175,7 @@ rps_connect_complete_cb (void *cls,
1075 */ 1175 */
1076static void * 1176static void *
1077rps_connect_adapter (void *cls, 1177rps_connect_adapter (void *cls,
1078 const struct GNUNET_CONFIGURATION_Handle *cfg) 1178 const struct GNUNET_CONFIGURATION_Handle *cfg)
1079{ 1179{
1080 struct GNUNET_RPS_Handle *h; 1180 struct GNUNET_RPS_Handle *h;
1081 1181
@@ -1167,15 +1267,26 @@ stat_complete_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
1167 */ 1267 */
1168static void 1268static void
1169rps_disconnect_adapter (void *cls, 1269rps_disconnect_adapter (void *cls,
1170 void *op_result) 1270 void *op_result)
1171{ 1271{
1172 struct RPSPeer *peer = cls; 1272 struct RPSPeer *peer = cls;
1173 struct GNUNET_RPS_Handle *h = op_result; 1273 struct GNUNET_RPS_Handle *h = op_result;
1274 struct PendingReply *pending_rep;
1174 1275
1175 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnect_adapter()\n"); 1276 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1277 "disconnect_adapter (%u)\n",
1278 peer->index);
1176 GNUNET_assert (NULL != peer); 1279 GNUNET_assert (NULL != peer);
1177 GNUNET_RPS_disconnect (h); 1280 if (NULL != peer->rps_handle)
1178 peer->rps_handle = NULL; 1281 {
1282 while (NULL != (pending_rep = peer->pending_rep_head))
1283 {
1284 cancel_request (pending_rep);
1285 }
1286 GNUNET_assert (h == peer->rps_handle);
1287 GNUNET_RPS_disconnect (h);
1288 peer->rps_handle = NULL;
1289 }
1179} 1290}
1180 1291
1181 1292
@@ -1219,13 +1330,15 @@ default_reply_handle (void *cls,
1219 rps_peer->num_recv_ids++; 1330 rps_peer->num_recv_ids++;
1220 } 1331 }
1221 1332
1222 if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit) 1333 if (GNUNET_YES != post_test) return;
1334 if (HAVE_QUICK_QUIT != cur_test_run.have_quick_quit) return;
1335 if (0 == evaluate())
1223 { 1336 {
1224 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n"); 1337 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1225 GNUNET_assert (NULL != post_test_task); 1338 "Test succeeded before end of duration\n");
1226 GNUNET_SCHEDULER_cancel (post_test_task); 1339 if (NULL != post_test_task) GNUNET_SCHEDULER_cancel (post_test_task);
1227 post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL); 1340 post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL);
1228 GNUNET_assert (NULL!= post_test_task); 1341 GNUNET_assert (NULL != post_test_task);
1229 } 1342 }
1230} 1343}
1231 1344
@@ -1239,13 +1352,13 @@ request_peers (void *cls)
1239 struct RPSPeer *rps_peer; 1352 struct RPSPeer *rps_peer;
1240 struct PendingReply *pending_rep; 1353 struct PendingReply *pending_rep;
1241 1354
1242 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
1243 return;
1244 rps_peer = pending_req->rps_peer; 1355 rps_peer = pending_req->rps_peer;
1245 GNUNET_assert (1 <= rps_peer->num_pending_reqs); 1356 GNUNET_assert (1 <= rps_peer->num_pending_reqs);
1246 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head, 1357 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head,
1247 rps_peer->pending_req_tail, 1358 rps_peer->pending_req_tail,
1248 pending_req); 1359 pending_req);
1360 rps_peer->num_pending_reqs--;
1361 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) return;
1249 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1250 "Requesting one peer\n"); 1363 "Requesting one peer\n");
1251 pending_rep = GNUNET_new (struct PendingReply); 1364 pending_rep = GNUNET_new (struct PendingReply);
@@ -1258,39 +1371,6 @@ request_peers (void *cls)
1258 rps_peer->pending_rep_tail, 1371 rps_peer->pending_rep_tail,
1259 pending_rep); 1372 pending_rep);
1260 rps_peer->num_pending_reps++; 1373 rps_peer->num_pending_reps++;
1261 rps_peer->num_pending_reqs--;
1262}
1263
1264static void
1265cancel_pending_req (struct PendingRequest *pending_req)
1266{
1267 struct RPSPeer *rps_peer;
1268
1269 rps_peer = pending_req->rps_peer;
1270 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head,
1271 rps_peer->pending_req_tail,
1272 pending_req);
1273 rps_peer->num_pending_reqs--;
1274 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1275 "Cancelling pending request\n");
1276 GNUNET_SCHEDULER_cancel (pending_req->request_task);
1277 GNUNET_free (pending_req);
1278}
1279
1280static void
1281cancel_request (struct PendingReply *pending_rep)
1282{
1283 struct RPSPeer *rps_peer;
1284
1285 rps_peer = pending_rep->rps_peer;
1286 GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head,
1287 rps_peer->pending_rep_tail,
1288 pending_rep);
1289 rps_peer->num_pending_reps--;
1290 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1291 "Cancelling request\n");
1292 GNUNET_RPS_request_cancel (pending_rep->req_handle);
1293 GNUNET_free (pending_rep);
1294} 1374}
1295 1375
1296 1376
@@ -2261,12 +2341,6 @@ void write_final_stats (void){
2261 stat_type < STAT_TYPE_MAX; 2341 stat_type < STAT_TYPE_MAX;
2262 stat_type++) 2342 stat_type++)
2263 { 2343 {
2264 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2265 "Add to sum (%" PRIu64 ") %" PRIu64 " of stat type %u - %s\n",
2266 sums[stat_type],
2267 rps_peers[i].stats[stat_type],
2268 stat_type,
2269 stat_type_2_str (stat_type));
2270 sums[stat_type] += rps_peers[i].stats[stat_type]; 2344 sums[stat_type] += rps_peers[i].stats[stat_type];
2271 } 2345 }
2272 } 2346 }
@@ -2312,6 +2386,8 @@ post_test_shutdown_ready_cb (void *cls,
2312{ 2386{
2313 struct STATcls *stat_cls = (struct STATcls *) cls; 2387 struct STATcls *stat_cls = (struct STATcls *) cls;
2314 struct RPSPeer *rps_peer = stat_cls->rps_peer; 2388 struct RPSPeer *rps_peer = stat_cls->rps_peer;
2389
2390 rps_peer->h_stat_get[stat_cls->stat_type] = NULL;
2315 if (GNUNET_OK == success) 2391 if (GNUNET_OK == success)
2316 { 2392 {
2317 /* set flag that we we got the value */ 2393 /* set flag that we we got the value */
@@ -2363,6 +2439,7 @@ stat_iterator (void *cls,
2363{ 2439{
2364 const struct STATcls *stat_cls = (const struct STATcls *) cls; 2440 const struct STATcls *stat_cls = (const struct STATcls *) cls;
2365 struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer; 2441 struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer;
2442
2366 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n", 2443 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n",
2367 //stat_type_2_str (stat_cls->stat_type), 2444 //stat_type_2_str (stat_cls->stat_type),
2368 name, 2445 name,
@@ -2455,12 +2532,13 @@ void post_profiler (struct RPSPeer *rps_peer)
2455 stat_cls->stat_type = stat_type; 2532 stat_cls->stat_type = stat_type;
2456 rps_peer->file_name_stats = 2533 rps_peer->file_name_stats =
2457 store_prefix_file_name (rps_peer->peer_id, "stats"); 2534 store_prefix_file_name (rps_peer->peer_id, "stats");
2458 GNUNET_STATISTICS_get (rps_peer->stats_h, 2535 rps_peer->h_stat_get[stat_type] = GNUNET_STATISTICS_get (
2459 "rps", 2536 rps_peer->stats_h,
2460 stat_type_2_str (stat_type), 2537 "rps",
2461 post_test_shutdown_ready_cb, 2538 stat_type_2_str (stat_type),
2462 stat_iterator, 2539 post_test_shutdown_ready_cb,
2463 (struct STATcls *) stat_cls); 2540 stat_iterator,
2541 (struct STATcls *) stat_cls);
2464 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2542 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2465 "Requested statistics for %s (peer %" PRIu32 ")\n", 2543 "Requested statistics for %s (peer %" PRIu32 ")\n",
2466 stat_type_2_str (stat_type), 2544 stat_type_2_str (stat_type),
@@ -2555,6 +2633,8 @@ test_run (void *cls,
2555 /* Connect all peers to statistics service */ 2633 /* Connect all peers to statistics service */
2556 if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics) 2634 if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics)
2557 { 2635 {
2636 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2637 "Connecting to statistics service\n");
2558 rps_peers[i].stat_op = 2638 rps_peers[i].stat_op =
2559 GNUNET_TESTBED_service_connect (NULL, 2639 GNUNET_TESTBED_service_connect (NULL,
2560 peers[i], 2640 peers[i],
@@ -2569,11 +2649,12 @@ test_run (void *cls,
2569 2649
2570 if (NULL != churn_task) 2650 if (NULL != churn_task)
2571 GNUNET_SCHEDULER_cancel (churn_task); 2651 GNUNET_SCHEDULER_cancel (churn_task);
2572 post_test_task = GNUNET_SCHEDULER_add_delayed (timeout, &post_test_op, NULL); 2652 post_test_task = GNUNET_SCHEDULER_add_delayed (duration, &post_test_op, NULL);
2573 timeout = GNUNET_TIME_relative_multiply (timeout, 1 + (0.1 * num_peers)); 2653 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "timeout for shutdown is %lu\n", timeout.rel_value_us/1000000);
2574 shutdown_task = GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL); 2654 shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout,
2575 shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); 2655 &trigger_shutdown,
2576 2656 NULL);
2657 GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL);
2577} 2658}
2578 2659
2579 2660
@@ -2609,7 +2690,7 @@ run (void *cls,
2609 if (0 == cur_test_run.num_requests) cur_test_run.num_requests = 5; 2690 if (0 == cur_test_run.num_requests) cur_test_run.num_requests = 5;
2610 //cur_test_run.have_churn = HAVE_CHURN; 2691 //cur_test_run.have_churn = HAVE_CHURN;
2611 cur_test_run.have_churn = HAVE_NO_CHURN; 2692 cur_test_run.have_churn = HAVE_NO_CHURN;
2612 cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT; 2693 cur_test_run.have_quick_quit = HAVE_QUICK_QUIT;
2613 cur_test_run.have_collect_statistics = COLLECT_STATISTICS; 2694 cur_test_run.have_collect_statistics = COLLECT_STATISTICS;
2614 cur_test_run.stat_collect_flags = BIT(STAT_TYPE_ROUNDS) | 2695 cur_test_run.stat_collect_flags = BIT(STAT_TYPE_ROUNDS) |
2615 BIT(STAT_TYPE_BLOCKS) | 2696 BIT(STAT_TYPE_BLOCKS) |
@@ -2632,10 +2713,38 @@ run (void *cls,
2632 /* 'Clean' directory */ 2713 /* 'Clean' directory */
2633 (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); 2714 (void) GNUNET_DISK_directory_remove ("/tmp/rps/");
2634 GNUNET_DISK_directory_create ("/tmp/rps/"); 2715 GNUNET_DISK_directory_create ("/tmp/rps/");
2635 if (0 == timeout.rel_value_us) 2716 if (0 == duration.rel_value_us)
2636 { 2717 {
2637 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); 2718 if (0 == timeout.rel_value_us)
2719 {
2720 duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90);
2721 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
2722 (90 * 1.2) +
2723 (0.01 * num_peers));
2724 }
2725 else
2726 {
2727 duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
2728 (timeout.rel_value_us/1000000)
2729 * 0.75);
2730 }
2638 } 2731 }
2732 else
2733 {
2734 if (0 == timeout.rel_value_us)
2735 {
2736 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
2737 ((duration.rel_value_us/1000000)
2738 * 1.2) + (0.01 * num_peers));
2739 }
2740 }
2741 GNUNET_assert (duration.rel_value_us < timeout.rel_value_us);
2742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2743 "duration is %lus\n",
2744 duration.rel_value_us/1000000);
2745 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2746 "timeout is %lus\n",
2747 timeout.rel_value_us/1000000);
2639 2748
2640 /* Compute number of bits for representing largest peer id */ 2749 /* Compute number of bits for representing largest peer id */
2641 for (bits_needed = 1; (1 << bits_needed) < num_peers; bits_needed++) 2750 for (bits_needed = 1; (1 << bits_needed) < num_peers; bits_needed++)
@@ -2685,6 +2794,12 @@ main (int argc, char *argv[])
2685 gettext_noop ("number of peers to start"), 2794 gettext_noop ("number of peers to start"),
2686 &num_peers), 2795 &num_peers),
2687 2796
2797 GNUNET_GETOPT_option_relative_time ('d',
2798 "duration",
2799 "DURATION",
2800 gettext_noop ("duration of the profiling"),
2801 &duration),
2802
2688 GNUNET_GETOPT_option_relative_time ('t', 2803 GNUNET_GETOPT_option_relative_time ('t',
2689 "timeout", 2804 "timeout",
2690 "TIMEOUT", 2805 "TIMEOUT",
@@ -2732,7 +2847,6 @@ main (int argc, char *argv[])
2732 GNUNET_free (rps_peers); 2847 GNUNET_free (rps_peers);
2733 GNUNET_free (rps_peer_ids); 2848 GNUNET_free (rps_peer_ids);
2734 GNUNET_CONTAINER_multipeermap_destroy (peer_map); 2849 GNUNET_CONTAINER_multipeermap_destroy (peer_map);
2735 printf ("test -1\n");
2736 return ret_value; 2850 return ret_value;
2737} 2851}
2738 2852