aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-18 16:47:01 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-18 16:47:01 +0000
commit64e514de7b7eae4e33cb576cfc39a0ea82d4021b (patch)
treed52e2faccbab84ff2c57814959c1abf75c2b54d7 /src/ats
parent8f3820b6244a0ac7fa28956413e17a6d3feb860c (diff)
downloadgnunet-64e514de7b7eae4e33cb576cfc39a0ea82d4021b.tar.gz
gnunet-64e514de7b7eae4e33cb576cfc39a0ea82d4021b.zip
- improve
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/perf_ats_mlp.c59
1 files changed, 41 insertions, 18 deletions
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c
index 63dce8b37..e25610c74 100644
--- a/src/ats/perf_ats_mlp.c
+++ b/src/ats/perf_ats_mlp.c
@@ -42,6 +42,9 @@ static unsigned int peers;
42static unsigned int addresses; 42static unsigned int addresses;
43static unsigned int numeric; 43static unsigned int numeric;
44 44
45static int start;
46static int end;
47
45struct PeerContext *p; 48struct PeerContext *p;
46struct ATS_Address *a; 49struct ATS_Address *a;
47 50
@@ -145,6 +148,14 @@ check (void *cls, char *const *args, const char *cfgfile,
145 amap = GNUNET_CONTAINER_multihashmap_create(addresses * peers); 148 amap = GNUNET_CONTAINER_multihashmap_create(addresses * peers);
146 149
147 mlp->auto_solve = GNUNET_NO; 150 mlp->auto_solve = GNUNET_NO;
151 if (start == 0)
152 start = 0;
153 if (end == 0)
154 end = -1;
155 if ((start != -1) && (end != -1))
156 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Solving problem starting from %u to %u\n", start , end);
157 else
158 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Solving problem for %u peers\n", peers);
148 for (c=0; c < peers; c++) 159 for (c=0; c < peers; c++)
149 { 160 {
150 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up peer %u\n", c); 161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up peer %u\n", c);
@@ -174,27 +185,33 @@ check (void *cls, char *const *args, const char *cfgfile,
174 GAS_mlp_address_update(mlp, amap, &a[ca]); 185 GAS_mlp_address_update(mlp, amap, &a[ca]);
175 ca++; 186 ca++;
176 } 187 }
177 }
178 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem);
179
180 GNUNET_assert (peers == mlp->c_p);
181 GNUNET_assert (peers * addresses == mlp->addr_in_problem);
182
183 /* Solving the problem */
184 struct GAS_MLP_SolutionContext ctx;
185 188
186 if (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx)) 189 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem);
187 {
188 GNUNET_assert (GNUNET_OK == ctx.lp_result);
189 GNUNET_assert (GNUNET_OK == ctx.mlp_result);
190 if (GNUNET_YES == numeric)
191 printf ("%u;%u;%llu;%llu\n",mlp->c_p, mlp->addr_in_problem, (long long unsigned int) ctx.lp_duration.rel_value, (long long unsigned int) ctx.mlp_duration.rel_value);
192 else
193 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solved successfully (LP: %llu ms / MLP: %llu ms)\n", ctx.lp_duration.rel_value, ctx.mlp_duration.rel_value);
194 190
191 if ((((start >= 0) && ((c+1) >= start)) && (c <= end)) || ((c+1) == peers))
192 {
193 GNUNET_assert ((c+1) == mlp->c_p);
194 GNUNET_assert ((c+1) * addresses == mlp->addr_in_problem);
195
196 /* Solving the problem */
197 struct GAS_MLP_SolutionContext ctx;
198
199 if (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx))
200 {
201 GNUNET_assert (GNUNET_OK == ctx.lp_result);
202 GNUNET_assert (GNUNET_OK == ctx.mlp_result);
203 if (GNUNET_YES == numeric)
204 printf ("%u;%u;%llu;%llu\n",mlp->c_p, mlp->addr_in_problem, (long long unsigned int) ctx.lp_duration.rel_value, (long long unsigned int) ctx.mlp_duration.rel_value);
205 else
206 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem solved for %u peers with %u address successfully (LP: %llu ms / MLP: %llu ms)\n",
207 mlp->c_p, mlp->addr_in_problem, ctx.lp_duration.rel_value, ctx.mlp_duration.rel_value);
208
209 }
210 else
211 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", peers, addresses);
212 }
195 } 213 }
196 else 214
197 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", peers, addresses);
198 if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) 215 if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
199 GNUNET_SCHEDULER_cancel(shutdown_task); 216 GNUNET_SCHEDULER_cancel(shutdown_task);
200 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 217 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
@@ -216,6 +233,12 @@ main (int argc, char *argv[])
216 {'n', "numeric", NULL, 233 {'n', "numeric", NULL,
217 gettext_noop ("numeric output only"), 0, 234 gettext_noop ("numeric output only"), 0,
218 &GNUNET_GETOPT_set_one, &numeric}, 235 &GNUNET_GETOPT_set_one, &numeric},
236 {'e', "end", NULL,
237 gettext_noop ("end solving problem"), 1,
238 &GNUNET_GETOPT_set_uint, &end},
239 {'s', "start", NULL,
240 gettext_noop ("start solving problem"), 1,
241 &GNUNET_GETOPT_set_uint, &start},
219 GNUNET_GETOPT_OPTION_END 242 GNUNET_GETOPT_OPTION_END
220 }; 243 };
221 244