diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-03-21 18:44:48 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-03-21 18:44:48 +0000 |
commit | 6b50d0090dfda491214c64569e64bb8a03b4648e (patch) | |
tree | dc83c34ff584ffc18ffff8195358228df67a64e3 /src/mesh/gnunet-mesh-profiler.c | |
parent | 51de20f3d259aec376595e625eac5c78c628e2fc (diff) | |
download | gnunet-6b50d0090dfda491214c64569e64bb8a03b4648e.tar.gz gnunet-6b50d0090dfda491214c64569e64bb8a03b4648e.zip |
-move round time to cli, fix config file
Diffstat (limited to 'src/mesh/gnunet-mesh-profiler.c')
-rw-r--r-- | src/mesh/gnunet-mesh-profiler.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/mesh/gnunet-mesh-profiler.c b/src/mesh/gnunet-mesh-profiler.c index d93fa6081..2f6026028 100644 --- a/src/mesh/gnunet-mesh-profiler.c +++ b/src/mesh/gnunet-mesh-profiler.c | |||
@@ -34,11 +34,6 @@ | |||
34 | 34 | ||
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Duration of each round. | ||
38 | */ | ||
39 | #define ROUND_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
40 | |||
41 | /** | ||
42 | * Paximum ping period in milliseconds. Real period = rand (0, PING_PERIOD) | 37 | * Paximum ping period in milliseconds. Real period = rand (0, PING_PERIOD) |
43 | */ | 38 | */ |
44 | #define PING_PERIOD 1000 | 39 | #define PING_PERIOD 1000 |
@@ -61,7 +56,7 @@ | |||
61 | /** | 56 | /** |
62 | * Ratio of peers active. First round always is 1.0. | 57 | * Ratio of peers active. First round always is 1.0. |
63 | */ | 58 | */ |
64 | static float rounds[] = {0.8, 0.6, 0.4, 0.2, 0.0}; | 59 | static float rounds[] = {0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.0}; |
65 | 60 | ||
66 | /** | 61 | /** |
67 | * Message type for pings. | 62 | * Message type for pings. |
@@ -157,6 +152,11 @@ struct MeshPeer | |||
157 | }; | 152 | }; |
158 | 153 | ||
159 | /** | 154 | /** |
155 | * Duration of each round. | ||
156 | */ | ||
157 | static struct GNUNET_TIME_Relative round_time; | ||
158 | |||
159 | /** | ||
160 | * GNUNET_PeerIdentity -> MeshPeer | 160 | * GNUNET_PeerIdentity -> MeshPeer |
161 | */ | 161 | */ |
162 | static struct GNUNET_CONTAINER_MultiPeerMap *ids; | 162 | static struct GNUNET_CONTAINER_MultiPeerMap *ids; |
@@ -525,7 +525,7 @@ next_rnd (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
525 | adjust_running_peers (rounds[current_round] * peers_total); | 525 | adjust_running_peers (rounds[current_round] * peers_total); |
526 | current_round++; | 526 | current_round++; |
527 | 527 | ||
528 | GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, NULL); | 528 | GNUNET_SCHEDULER_add_delayed (round_time, &next_rnd, NULL); |
529 | } | 529 | } |
530 | 530 | ||
531 | 531 | ||
@@ -844,11 +844,11 @@ start_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
844 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) | 844 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) |
845 | GNUNET_SCHEDULER_cancel (disconnect_task); | 845 | GNUNET_SCHEDULER_cancel (disconnect_task); |
846 | disconnect_task = | 846 | disconnect_task = |
847 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(ROUND_TIME, | 847 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(round_time, |
848 | number_rounds + 1), | 848 | number_rounds + 1), |
849 | &disconnect_mesh_peers, | 849 | &disconnect_mesh_peers, |
850 | (void *) __LINE__); | 850 | (void *) __LINE__); |
851 | GNUNET_SCHEDULER_add_delayed (ROUND_TIME, &next_rnd, NULL); | 851 | GNUNET_SCHEDULER_add_delayed (round_time, &next_rnd, NULL); |
852 | } | 852 | } |
853 | 853 | ||
854 | 854 | ||
@@ -947,12 +947,20 @@ main (int argc, char *argv[]) | |||
947 | 947 | ||
948 | config_file = ".profiler.conf"; | 948 | config_file = ".profiler.conf"; |
949 | 949 | ||
950 | if (3 > argc) | 950 | if (4 > argc) |
951 | { | ||
952 | fprintf (stderr, "usage: %s ROUND_TIME PEERS PINGS\n", argv[0]); | ||
953 | fprintf (stderr, "example: %s 30s 16 1\n", argv[0]); | ||
954 | return 1; | ||
955 | } | ||
956 | |||
957 | if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (argv[1], &round_time)) | ||
951 | { | 958 | { |
952 | fprintf (stderr, "usage: %s PEERS PINGS\n", argv[0]); | 959 | fprintf (stderr, "%s is not a valid time\n", argv[1]); |
953 | return 1; | 960 | return 1; |
954 | } | 961 | } |
955 | peers_total = atoll (argv[1]); | 962 | |
963 | peers_total = atoll (argv[2]); | ||
956 | if (2 > peers_total) | 964 | if (2 > peers_total) |
957 | { | 965 | { |
958 | fprintf (stderr, "%s peers is not valid (> 2)\n", argv[1]); | 966 | fprintf (stderr, "%s peers is not valid (> 2)\n", argv[1]); |
@@ -960,7 +968,7 @@ main (int argc, char *argv[]) | |||
960 | } | 968 | } |
961 | peers = GNUNET_malloc (sizeof (struct MeshPeer) * peers_total); | 969 | peers = GNUNET_malloc (sizeof (struct MeshPeer) * peers_total); |
962 | 970 | ||
963 | peers_pinging = atoll (argv[2]); | 971 | peers_pinging = atoll (argv[3]); |
964 | 972 | ||
965 | if (peers_total < 2 * peers_pinging) | 973 | if (peers_total < 2 * peers_pinging) |
966 | { | 974 | { |