aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-18 10:27:15 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-18 10:27:15 +0000
commit2a6c19e8b67a36fa07cde86adde1cf9eeed77dd8 (patch)
tree15b547a30cd31dc30d897486afb3fc20378374ba /src/ats
parent9458bb0f06206d74f4e8e7a4cdadd0d2b579a340 (diff)
downloadgnunet-2a6c19e8b67a36fa07cde86adde1cf9eeed77dd8.tar.gz
gnunet-2a6c19e8b67a36fa07cde86adde1cf9eeed77dd8.zip
- fixes
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/gnunet-service-ats_addresses_mlp.c33
-rw-r--r--src/ats/perf_ats_mlp.c39
2 files changed, 52 insertions, 20 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c
index f16832ecf..dfb62e665 100644
--- a/src/ats/gnunet-service-ats_addresses_mlp.c
+++ b/src/ats/gnunet-service-ats_addresses_mlp.c
@@ -883,9 +883,6 @@ lp_solv:
883 GNUNET_STATISTICS_set (mlp->stats,"# LP execution time average (ms)", 883 GNUNET_STATISTICS_set (mlp->stats,"# LP execution time average (ms)",
884 mlp->lp_total_duration / mlp->lp_solved, GNUNET_NO); 884 mlp->lp_total_duration / mlp->lp_solved, GNUNET_NO);
885 885
886 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
887 "ats-mlp",
888 "%llu %llu \n", duration.rel_value, mlp->lp_total_duration / mlp->lp_solved);
889 /* Analyze problem status */ 886 /* Analyze problem status */
890 res = glp_get_status (mlp->prob); 887 res = glp_get_status (mlp->prob);
891 switch (res) { 888 switch (res) {
@@ -1121,12 +1118,30 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1121 char * quota_in_str; 1118 char * quota_in_str;
1122 1119
1123 /* Init GLPK environment */ 1120 /* Init GLPK environment */
1124 int res = 0; 1121 int res = glp_init_env();
1125 if (0 != (res = glp_init_env())) 1122 switch (res) {
1126 { 1123 case 0:
1127 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK %u\n", res); 1124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n",
1128 GNUNET_free(mlp); 1125 "initialization successful");
1129 return NULL; 1126 break;
1127 case 1:
1128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GLPK: `%s'\n",
1129 "environment is already initialized");
1130 break;
1131 case 2:
1132 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n",
1133 "initialization failed (insufficient memory)");
1134 GNUNET_free(mlp);
1135 return NULL;
1136 break;
1137 case 3:
1138 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not init GLPK: `%s'\n",
1139 "initialization failed (unsupported programming model)");
1140 GNUNET_free(mlp);
1141 return NULL;
1142 break;
1143 default:
1144 break;
1130 } 1145 }
1131 1146
1132 /* Create initial MLP problem */ 1147 /* Create initial MLP problem */
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c
index 24590e68a..623f187ea 100644
--- a/src/ats/perf_ats_mlp.c
+++ b/src/ats/perf_ats_mlp.c
@@ -40,6 +40,7 @@
40 40
41static unsigned int peers; 41static unsigned int peers;
42static unsigned int addresses; 42static unsigned int addresses;
43static unsigned int numeric;
43 44
44struct PeerContext *p; 45struct PeerContext *p;
45struct ATS_Address *a; 46struct ATS_Address *a;
@@ -84,6 +85,15 @@ do_shutdown (void *cls,
84 const struct GNUNET_SCHEDULER_TaskContext *tc) 85 const struct GNUNET_SCHEDULER_TaskContext *tc)
85{ 86{
86 unsigned int ca; 87 unsigned int ca;
88
89 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
90
91 if (NULL != mlp)
92 {
93 GAS_mlp_done (mlp);
94 mlp = NULL;
95 }
96
87 if (NULL != a) 97 if (NULL != a)
88 { 98 {
89 for (ca=0; ca < (peers * addresses); ca++) 99 for (ca=0; ca < (peers * addresses); ca++)
@@ -92,8 +102,6 @@ do_shutdown (void *cls,
92 GNUNET_free (a[ca].ats); 102 GNUNET_free (a[ca].ats);
93 } 103 }
94 } 104 }
95 if (NULL != mlp)
96 GAS_mlp_done (mlp);
97 105
98 if (NULL != amap) 106 if (NULL != amap)
99 GNUNET_CONTAINER_multihashmap_destroy(amap); 107 GNUNET_CONTAINER_multihashmap_destroy(amap);
@@ -117,22 +125,28 @@ int stat_lp_it (void *cls, const char *subsystem,
117 const char *name, uint64_t value, 125 const char *name, uint64_t value,
118 int is_persistent) 126 int is_persistent)
119{ 127{
120 GNUNET_break (0);
121 static int calls;
122 static long long unsigned lp_time; 128 static long long unsigned lp_time;
123 static long long unsigned mlp_time; 129 static long long unsigned mlp_time;
130 static long long unsigned lp_time_set;
131 static long long unsigned mlp_time_set;
132
133 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received: `%s' : %u \n", name, value);
124 134
125 if (0 == strcmp (name, "# LP execution time (ms)")) 135 if (0 == strcmp (name, "# LP execution time (ms)"))
136 {
126 lp_time = value; 137 lp_time = value;
138 lp_time_set = GNUNET_YES;
139 }
127 if (0 == strcmp (name, "# MLP execution time (ms)")) 140 if (0 == strcmp (name, "# MLP execution time (ms)"))
141 {
128 mlp_time = value; 142 mlp_time = value;
143 mlp_time_set = GNUNET_YES;
144 }
129 145
130 GNUNET_break (0); 146 if ((GNUNET_YES == lp_time_set) && (GNUNET_YES == mlp_time_set))
131 calls ++;
132
133 if (2 == calls)
134 { 147 {
135 printf ("%u;%u;%llu;%llu\n",peers, addresses, lp_time, mlp_time); 148 if (GNUNET_YES == numeric)
149 printf ("%u;%u;%llu;%llu\n",peers, addresses, lp_time, mlp_time);
136 if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) 150 if (GNUNET_SCHEDULER_NO_TASK != shutdown_task)
137 GNUNET_SCHEDULER_cancel(shutdown_task); 151 GNUNET_SCHEDULER_cancel(shutdown_task);
138 shutdown_task = GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); 152 shutdown_task = GNUNET_SCHEDULER_add_now(&do_shutdown, NULL);
@@ -149,7 +163,7 @@ int stat_ready_it (void *cls, const char *subsystem,
149 unsigned int ca = 0; 163 unsigned int ca = 0;
150 struct GNUNET_CONFIGURATION_Handle *cfg = cls; 164 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
151 165
152 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Statistics service ready\n"); 166 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Statistics service ready\n");
153 167
154 GNUNET_STATISTICS_watch (stats, "ats", "# LP execution time (ms)", &stat_lp_it, NULL); 168 GNUNET_STATISTICS_watch (stats, "ats", "# LP execution time (ms)", &stat_lp_it, NULL);
155 GNUNET_STATISTICS_watch (stats, "ats", "# MLP execution time (ms)", &stat_lp_it, NULL); 169 GNUNET_STATISTICS_watch (stats, "ats", "# MLP execution time (ms)", &stat_lp_it, NULL);
@@ -215,7 +229,7 @@ int stat_ready_it (void *cls, const char *subsystem,
215 229
216 /* Solving the problem */ 230 /* Solving the problem */
217 if (GNUNET_OK == GAS_mlp_solve_problem(mlp)) 231 if (GNUNET_OK == GAS_mlp_solve_problem(mlp))
218 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solved successfully \n"); 232 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved successfully \n");
219 else 233 else
220 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", peers, addresses); 234 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", peers, addresses);
221 235
@@ -267,6 +281,9 @@ main (int argc, char *argv[])
267 {'p', "peers", NULL, 281 {'p', "peers", NULL,
268 gettext_noop ("peers"), 1, 282 gettext_noop ("peers"), 1,
269 &GNUNET_GETOPT_set_uint, &peers}, 283 &GNUNET_GETOPT_set_uint, &peers},
284 {'n', "numeric", NULL,
285 gettext_noop ("numeric output only"), 0,
286 &GNUNET_GETOPT_set_one, &numeric},
270 GNUNET_GETOPT_OPTION_END 287 GNUNET_GETOPT_OPTION_END
271 }; 288 };
272 289