aboutsummaryrefslogtreecommitdiff
path: root/src/transport/perf_transport_ats.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
commit502af2167f7c218366666ca4944bd7cc54b5b19a (patch)
treea91fec5cc9769d260640bd91c6633cb9cf395524 /src/transport/perf_transport_ats.c
parent03af5a603b7cc53432249d5854cd412aa90dde0d (diff)
downloadgnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.tar.gz
gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.zip
indentation
Diffstat (limited to 'src/transport/perf_transport_ats.c')
-rw-r--r--src/transport/perf_transport_ats.c213
1 files changed, 107 insertions, 106 deletions
diff --git a/src/transport/perf_transport_ats.c b/src/transport/perf_transport_ats.c
index 3f8950a8a..df1ebe950 100644
--- a/src/transport/perf_transport_ats.c
+++ b/src/transport/perf_transport_ats.c
@@ -40,48 +40,51 @@ static uint64_t sim_with_opt_avg;
40static uint64_t mlp_no_opt_avg; 40static uint64_t mlp_no_opt_avg;
41static uint64_t mlp_with_opt_avg; 41static uint64_t mlp_with_opt_avg;
42 42
43static glp_prob * prob; 43static glp_prob *prob;
44 44
45static struct GNUNET_TIME_Absolute start; 45static struct GNUNET_TIME_Absolute start;
46static struct GNUNET_TIME_Absolute end; 46static struct GNUNET_TIME_Absolute end;
47 47
48static void 48static void
49solve_mlp(int presolve) 49solve_mlp (int presolve)
50{ 50{
51 int result, solution; 51 int result, solution;
52 glp_iocp opt_mlp; 52 glp_iocp opt_mlp;
53 53
54 glp_init_iocp(&opt_mlp); 54 glp_init_iocp (&opt_mlp);
55 opt_mlp.msg_lev = GLP_MSG_OFF; 55 opt_mlp.msg_lev = GLP_MSG_OFF;
56 opt_mlp.presolve = GLP_OFF; 56 opt_mlp.presolve = GLP_OFF;
57 57
58 result = glp_intopt (prob, &opt_mlp); 58 result = glp_intopt (prob, &opt_mlp);
59 solution = glp_mip_status (prob); 59 solution = glp_mip_status (prob);
60 GNUNET_assert ((solution == 5) && (result==0)); 60 GNUNET_assert ((solution == 5) && (result == 0));
61} 61}
62 62
63static void 63static void
64solve_lp(int presolve) 64solve_lp (int presolve)
65{ 65{
66 int result; 66 int result;
67 int solution; 67 int solution;
68 68
69 glp_smcp opt_lp; 69 glp_smcp opt_lp;
70 glp_init_smcp(&opt_lp);
71 70
72 opt_lp.msg_lev = GLP_MSG_OFF; 71 glp_init_smcp (&opt_lp);
73 if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON;
74 else opt_lp.presolve = GLP_OFF;
75 72
76 result = glp_simplex(prob, &opt_lp); 73 opt_lp.msg_lev = GLP_MSG_OFF;
77 solution = glp_get_status (prob); 74 if (presolve == GNUNET_YES)
78 GNUNET_assert ((solution == 5) && (result==0)); 75 opt_lp.presolve = GLP_ON;
76 else
77 opt_lp.presolve = GLP_OFF;
78
79 result = glp_simplex (prob, &opt_lp);
80 solution = glp_get_status (prob);
81 GNUNET_assert ((solution == 5) && (result == 0));
79} 82}
80 83
81#if 0 84#if 0
82/* Modify quality constraint */ 85/* Modify quality constraint */
83static void 86static void
84modify_qm(int start, int length, int values_to_change) 87modify_qm (int start, int length, int values_to_change)
85{ 88{
86 //int * ind = GNUNET_malloc (length * sizeof (int)); 89 //int * ind = GNUNET_malloc (length * sizeof (int));
87 //double *val = GNUNET_malloc (length * sizeof (double)); 90 //double *val = GNUNET_malloc (length * sizeof (double));
@@ -89,15 +92,16 @@ modify_qm(int start, int length, int values_to_change)
89 double val[1000]; 92 double val[1000];
90 93
91 int res = 0; 94 int res = 0;
92 int c = start, c2=1; 95 int c = start, c2 = 1;
93 while (c<=(start+values_to_change)) 96
97 while (c <= (start + values_to_change))
94 { 98 {
95 res = glp_get_mat_row(prob, c, ind, val); 99 res = glp_get_mat_row (prob, c, ind, val);
96 100
97 printf("%i %i \n", c, res); 101 printf ("%i %i \n", c, res);
98 for (c2=0; c2<res; c2++) 102 for (c2 = 0; c2 < res; c2++)
99 { 103 {
100 printf("%i = %f \n", ind[c2], val[c2]); 104 printf ("%i = %f \n", ind[c2], val[c2]);
101 } 105 }
102 c++; 106 c++;
103 } 107 }
@@ -107,162 +111,158 @@ modify_qm(int start, int length, int values_to_change)
107 111
108 112
109 113
110static void 114static void
111bench_simplex_optimization(char * file, int executions) 115bench_simplex_optimization (char *file, int executions)
112{ 116{
113 int c; 117 int c;
114 int res; 118 int res;
115 119
116 prob = glp_create_prob(); 120 prob = glp_create_prob ();
117 res = glp_read_lp(prob, NULL, file); 121 res = glp_read_lp (prob, NULL, file);
118 if (res != 0) 122 if (res != 0)
119 { 123 {
120 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 124 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem file `%s' not found\n", file);
121 "Problem file `%s' not found\n", file);
122 ret = 1; 125 ret = 1;
123 return; 126 return;
124 } 127 }
125 128
126 solve_lp(GNUNET_YES); 129 solve_lp (GNUNET_YES);
127 130
128 for (c=0; c<executions;c++) 131 for (c = 0; c < executions; c++)
129 { 132 {
130 start = GNUNET_TIME_absolute_get(); 133 start = GNUNET_TIME_absolute_get ();
131 solve_lp(GNUNET_NO); 134 solve_lp (GNUNET_NO);
132 end = GNUNET_TIME_absolute_get(); 135 end = GNUNET_TIME_absolute_get ();
133 136
134 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 137 exec_time[c] = GNUNET_TIME_absolute_get_difference (start, end).rel_value;
135 138
136 sim_with_opt_avg += exec_time[c]; 139 sim_with_opt_avg += exec_time[c];
137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 140 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
138 "Simplex /w optimization iterations %i: %llu \n", c, exec_time[c]); 141 "Simplex /w optimization iterations %i: %llu \n", c,
142 exec_time[c]);
139 } 143 }
140 144
141 glp_delete_prob(prob); 145 glp_delete_prob (prob);
142} 146}
143 147
144 148
145static void 149static void
146bench_simplex_no_optimization(char * file, int executions) 150bench_simplex_no_optimization (char *file, int executions)
147{ 151{
148 int c; 152 int c;
149 int res; 153 int res;
150 154
151 prob = glp_create_prob(); 155 prob = glp_create_prob ();
152 res = glp_read_lp(prob, NULL, file); 156 res = glp_read_lp (prob, NULL, file);
153 if (res != 0) 157 if (res != 0)
154 { 158 {
155 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 159 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem file `%s' not found\n", file);
156 "Problem file `%s' not found\n", file);
157 ret = 1; 160 ret = 1;
158 return; 161 return;
159 } 162 }
160 163
161 for (c=0; c<executions;c++) 164 for (c = 0; c < executions; c++)
162 { 165 {
163 start = GNUNET_TIME_absolute_get(); 166 start = GNUNET_TIME_absolute_get ();
164 solve_lp(GNUNET_YES); 167 solve_lp (GNUNET_YES);
165 end = GNUNET_TIME_absolute_get(); 168 end = GNUNET_TIME_absolute_get ();
166 169
167 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 170 exec_time[c] = GNUNET_TIME_absolute_get_difference (start, end).rel_value;
168 171
169 sim_no_opt_avg += exec_time[c]; 172 sim_no_opt_avg += exec_time[c];
170 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
171 "Simplex iterations %i: %llu \n", 174 "Simplex iterations %i: %llu \n", c, exec_time[c]);
172 c, exec_time[c]);
173 } 175 }
174 176
175 glp_delete_prob(prob); 177 glp_delete_prob (prob);
176} 178}
177 179
178static void 180static void
179bench_mlp_no_optimization(char * file, int executions) 181bench_mlp_no_optimization (char *file, int executions)
180{ 182{
181 int c; 183 int c;
182 int res; 184 int res;
183 185
184 prob = glp_create_prob(); 186 prob = glp_create_prob ();
185 res = glp_read_lp(prob, NULL, file); 187 res = glp_read_lp (prob, NULL, file);
186 if (res != 0) 188 if (res != 0)
187 { 189 {
188 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 190 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem file `%s' not found\n", file);
189 "Problem file `%s' not found\n", file);
190 ret = 1; 191 ret = 1;
191 return; 192 return;
192 } 193 }
193 for (c=0; c<executions;c++) 194 for (c = 0; c < executions; c++)
194 { 195 {
195 start = GNUNET_TIME_absolute_get(); 196 start = GNUNET_TIME_absolute_get ();
196 solve_lp(GNUNET_YES); 197 solve_lp (GNUNET_YES);
197 solve_mlp (GNUNET_NO); 198 solve_mlp (GNUNET_NO);
198 end = GNUNET_TIME_absolute_get(); 199 end = GNUNET_TIME_absolute_get ();
199 200
200 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 201 exec_time[c] = GNUNET_TIME_absolute_get_difference (start, end).rel_value;
201 202
202 mlp_no_opt_avg += exec_time[c]; 203 mlp_no_opt_avg += exec_time[c];
203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
204 "MLP iterations no optimization %i: %llu \n", 205 "MLP iterations no optimization %i: %llu \n", c, exec_time[c]);
205 c, exec_time[c]);
206 } 206 }
207 207
208 glp_delete_prob(prob); 208 glp_delete_prob (prob);
209} 209}
210 210
211 211
212static void 212static void
213bench_mlp_with_optimization(char * file, int executions, int changes) 213bench_mlp_with_optimization (char *file, int executions, int changes)
214{ 214{
215 int c; 215 int c;
216 int res; 216 int res;
217 217
218 prob = glp_create_prob(); 218 prob = glp_create_prob ();
219 res = glp_read_lp(prob, NULL, file); 219 res = glp_read_lp (prob, NULL, file);
220 if (res != 0) 220 if (res != 0)
221 { 221 {
222 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 222 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem file `%s' not found\n", file);
223 "Problem file `%s' not found\n", file);
224 ret = 1; 223 ret = 1;
225 return; 224 return;
226 } 225 }
227 226
228 solve_lp(GNUNET_YES); 227 solve_lp (GNUNET_YES);
229 228
230 for (c=0; c<executions;c++) 229 for (c = 0; c < executions; c++)
231 { 230 {
232 start = GNUNET_TIME_absolute_get(); 231 start = GNUNET_TIME_absolute_get ();
233 //modify_qm(906, 0, 0); 232 //modify_qm(906, 0, 0);
234 solve_lp(GNUNET_NO); 233 solve_lp (GNUNET_NO);
235 solve_mlp (GNUNET_NO); 234 solve_mlp (GNUNET_NO);
236 end = GNUNET_TIME_absolute_get(); 235 end = GNUNET_TIME_absolute_get ();
237 236
238 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 237 exec_time[c] = GNUNET_TIME_absolute_get_difference (start, end).rel_value;
239 238
240 mlp_with_opt_avg += exec_time[c]; 239 mlp_with_opt_avg += exec_time[c];
241 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
242 "MLP /w optimization iterations %i: %llu \n", 241 "MLP /w optimization iterations %i: %llu \n", c, exec_time[c]);
243 c, exec_time[c]);
244 } 242 }
245 243
246 glp_delete_prob(prob); 244 glp_delete_prob (prob);
247} 245}
248 246
249#if 0 247#if 0
250void modify_cr (int start, int length, int count) 248void
249modify_cr (int start, int length, int count)
251{ 250{
252 //int * ind = GNUNET_malloc (length * sizeof (int)); 251 //int * ind = GNUNET_malloc (length * sizeof (int));
253 //double *val = GNUNET_malloc (length * sizeof (double)); 252 //double *val = GNUNET_malloc (length * sizeof (double));
254 int ind[500]; 253 int ind[500];
255 double val[500]; 254 double val[500];
256 int res = 0; 255 int res = 0;
257 int c = start, c2=1; 256 int c = start, c2 = 1;
258 while (c<=(start+count)) 257
258 while (c <= (start + count))
259 { 259 {
260 res = glp_get_mat_row(prob, c, ind, val); 260 res = glp_get_mat_row (prob, c, ind, val);
261 261
262 printf("row index: %i non-zero elements: %i \n", c, res); 262 printf ("row index: %i non-zero elements: %i \n", c, res);
263 for (c2=1; c2<=res; c2++) 263 for (c2 = 1; c2 <= res; c2++)
264 { 264 {
265 printf("%i = %f ", ind[c2], val[c2]); 265 printf ("%i = %f ", ind[c2], val[c2]);
266 } 266 }
267 c++; 267 c++;
268 printf ("\n----\n"); 268 printf ("\n----\n");
@@ -272,7 +272,8 @@ void modify_cr (int start, int length, int count)
272#endif 272#endif
273 273
274 274
275int main (int argc, char *argv[]) 275int
276main (int argc, char *argv[])
276{ 277{
277 278
278 GNUNET_log_setup ("perf-transport-ats", 279 GNUNET_log_setup ("perf-transport-ats",
@@ -283,6 +284,7 @@ int main (int argc, char *argv[])
283#endif 284#endif
284 NULL); 285 NULL);
285 int nullfd = OPEN ("/dev/null", O_RDWR | O_APPEND); 286 int nullfd = OPEN ("/dev/null", O_RDWR | O_APPEND);
287
286 if (nullfd < 0) 288 if (nullfd < 0)
287 return GNUNET_SYSERR; 289 return GNUNET_SYSERR;
288 if (dup2 (nullfd, 1) < 0) 290 if (dup2 (nullfd, 1) < 0)
@@ -293,7 +295,7 @@ int main (int argc, char *argv[])
293 } 295 }
294 296
295 297
296 char * file = "ats_mlp_p100_m400.problem"; 298 char *file = "ats_mlp_p100_m400.problem";
297 299
298 bench_simplex_no_optimization (file, executions); 300 bench_simplex_no_optimization (file, executions);
299 bench_simplex_optimization (file, executions); 301 bench_simplex_optimization (file, executions);
@@ -305,33 +307,32 @@ int main (int argc, char *argv[])
305 307
306 // -> 400 addresses 308 // -> 400 addresses
307 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 309 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
308 "Simplex, no optimization, average per address: %f\n", 310 "Simplex, no optimization, average per address: %f\n",
309 ((double) sim_no_opt_avg / EXECS) / 400); 311 ((double) sim_no_opt_avg / EXECS) / 400);
310 GAUGER ("TRANSPORT","GLPK simplex no optimization", 312 GAUGER ("TRANSPORT", "GLPK simplex no optimization",
311 ((double) sim_no_opt_avg / EXECS) / 400, "ms/address"); 313 ((double) sim_no_opt_avg / EXECS) / 400, "ms/address");
312 314
313 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 315 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
314 "Simplex, with optimization, average per address: %f\n", 316 "Simplex, with optimization, average per address: %f\n",
315 ((double) sim_with_opt_avg / EXECS) / 400); 317 ((double) sim_with_opt_avg / EXECS) / 400);
316 GAUGER ("TRANSPORT", 318 GAUGER ("TRANSPORT",
317 "GLPK simplex, 100 peers 400 addresses with optimization", 319 "GLPK simplex, 100 peers 400 addresses with optimization",
318 ((double) sim_with_opt_avg / EXECS) / 400, "ms/address"); 320 ((double) sim_with_opt_avg / EXECS) / 400, "ms/address");
319 321
320 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 322 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
321 "MLP no optimization average per address: %f\n", 323 "MLP no optimization average per address: %f\n",
322 ((double) mlp_no_opt_avg / EXECS) / 400); 324 ((double) mlp_no_opt_avg / EXECS) / 400);
323 GAUGER ("TRANSPORT","GLPK MLP 100 peers 400 addresses no optimization", 325 GAUGER ("TRANSPORT", "GLPK MLP 100 peers 400 addresses no optimization",
324 ((double) mlp_no_opt_avg / EXECS) / 400, "ms/address"); 326 ((double) mlp_no_opt_avg / EXECS) / 400, "ms/address");
325 327
326 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 328 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
327 "MLP optimization average per address: %f\n", 329 "MLP optimization average per address: %f\n",
328 ((double) mlp_with_opt_avg/ EXECS) / 400); 330 ((double) mlp_with_opt_avg / EXECS) / 400);
329 GAUGER ("TRANSPORT", 331 GAUGER ("TRANSPORT",
330 "GLPK MLP 100 peers 400 addresses with optimization", 332 "GLPK MLP 100 peers 400 addresses with optimization",
331 ((double) mlp_with_opt_avg / EXECS) / 400, "ms/address"); 333 ((double) mlp_with_opt_avg / EXECS) / 400, "ms/address");
332 (void) CLOSE (nullfd); 334 (void) CLOSE (nullfd);
333 return ret; 335 return ret;
334} 336}
335 337
336/* end of perf_transport_ats.c*/ 338/* end of perf_transport_ats.c*/
337