aboutsummaryrefslogtreecommitdiff
path: root/src/transport/perf_transport_ats.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-06-05 13:07:13 +0000
committerChristian Grothoff <christian@grothoff.org>2011-06-05 13:07:13 +0000
commit187f3ee1b6edac986b7bc46c62c86a138290b147 (patch)
tree809c2751509e7111ad26e802e5df8d2332c24455 /src/transport/perf_transport_ats.c
parent2850662595ec7d25aaaf9674e987449375960c23 (diff)
downloadgnunet-187f3ee1b6edac986b7bc46c62c86a138290b147.tar.gz
gnunet-187f3ee1b6edac986b7bc46c62c86a138290b147.zip
adapting testcases to use new API
Diffstat (limited to 'src/transport/perf_transport_ats.c')
-rw-r--r--src/transport/perf_transport_ats.c361
1 files changed, 198 insertions, 163 deletions
diff --git a/src/transport/perf_transport_ats.c b/src/transport/perf_transport_ats.c
index 1f168b661..d95e02d2b 100644
--- a/src/transport/perf_transport_ats.c
+++ b/src/transport/perf_transport_ats.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors) 3 (C) 2010, 2011 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -18,7 +18,7 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20/** 20/**
21 * @file testing/per_transport_ats.c 21 * @file testing/perf_transport_ats.c
22 * @brief testcase for ats functionality 22 * @brief testcase for ats functionality
23 */ 23 */
24#include "platform.h" 24#include "platform.h"
@@ -48,217 +48,252 @@ static struct GNUNET_TIME_Absolute start;
48static struct GNUNET_TIME_Absolute end; 48static struct GNUNET_TIME_Absolute end;
49 49
50 50
51void solve_mlp(int presolve) 51static void
52solve_mlp(int presolve)
52{ 53{
53 int result, solution; 54 int result, solution;
54 55
55 glp_iocp opt_mlp; 56 glp_iocp opt_mlp;
56 glp_init_iocp(&opt_mlp); 57 glp_init_iocp(&opt_mlp);
57 opt_mlp.msg_lev = GLP_MSG_OFF; 58 opt_mlp.msg_lev = GLP_MSG_OFF;
58 opt_mlp.presolve = GLP_OFF; 59 opt_mlp.presolve = GLP_OFF;
59 60
60 result = glp_intopt (prob, &opt_mlp); 61 result = glp_intopt (prob, &opt_mlp);
61 solution = glp_mip_status (prob); 62 solution = glp_mip_status (prob);
62 GNUNET_assert ((solution == 5) && (result==0)); 63 GNUNET_assert ((solution == 5) && (result==0));
63} 64}
64 65
65void solve_lp(int presolve) 66static void
67solve_lp(int presolve)
66{ 68{
67 int result, solution; 69 int result, solution;
68 70
69 glp_smcp opt_lp; 71 glp_smcp opt_lp;
70 glp_init_smcp(&opt_lp); 72 glp_init_smcp(&opt_lp);
71 73
72 opt_lp.msg_lev = GLP_MSG_OFF; 74 opt_lp.msg_lev = GLP_MSG_OFF;
73 if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON; 75 if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON;
74 else opt_lp.presolve = GLP_OFF; 76 else opt_lp.presolve = GLP_OFF;
75 77
76 result = glp_simplex(prob, &opt_lp); 78 result = glp_simplex(prob, &opt_lp);
77 solution = glp_get_status (prob); 79 solution = glp_get_status (prob);
78 GNUNET_assert ((solution == 5) && (result==0)); 80 GNUNET_assert ((solution == 5) && (result==0));
79} 81}
80 82
83#if 0
81/* Modify quality constraint */ 84/* Modify quality constraint */
82void modify_qm(int start, int length, int values_to_change) 85static void
86modify_qm(int start, int length, int values_to_change)
83{ 87{
84 //int * ind = GNUNET_malloc (length * sizeof (int)); 88 //int * ind = GNUNET_malloc (length * sizeof (int));
85 //double *val = GNUNET_malloc (length * sizeof (double)); 89 //double *val = GNUNET_malloc (length * sizeof (double));
86 int ind[1000]; 90 int ind[1000];
87 double val[1000]; 91 double val[1000];
88 92
89 int res = 0; 93 int res = 0;
90 int c = start, c2=1; 94 int c = start, c2=1;
91 while (c<=(start+values_to_change)) 95 while (c<=(start+values_to_change))
96 {
97 res = glp_get_mat_row(prob, c, ind, val);
98
99 printf("%i %i \n", c, res);
100 for (c2=0; c2<res; c2++)
92 { 101 {
93 res = glp_get_mat_row(prob, c, ind, val); 102 printf("%i = %f \n", ind[c2], val[c2]);
94
95 printf("%i %i \n", c, res);
96 for (c2=0; c2<res; c2++)
97 {
98 printf("%i = %f \n", ind[c2], val[c2]);
99 }
100
101 c++;
102 } 103 }
103 //glp_set_mat_row(prob, start, length, ind, val); 104
105 c++;
106 }
107 //glp_set_mat_row(prob, start, length, ind, val);
104} 108}
109#endif
105 110
106 111
107 112static void
108void bench_simplex_optimization(char * file, int executions) 113bench_simplex_optimization(char * file, int executions)
109{ 114{
110 115
111 int c; 116 int c;
112 prob = glp_create_prob(); 117 prob = glp_create_prob();
113 glp_read_lp(prob, NULL, file); 118 glp_read_lp(prob, NULL, file);
114 119
115 solve_lp(GNUNET_YES); 120 solve_lp(GNUNET_YES);
116 121
117 for (c=0; c<executions;c++) 122 for (c=0; c<executions;c++)
118 { 123 {
119 start = GNUNET_TIME_absolute_get(); 124 start = GNUNET_TIME_absolute_get();
120 solve_lp(GNUNET_NO); 125 solve_lp(GNUNET_NO);
121 end = GNUNET_TIME_absolute_get(); 126 end = GNUNET_TIME_absolute_get();
122 127
123 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 128 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
124 129
125 sim_with_opt_avg += exec_time[c]; 130 sim_with_opt_avg += exec_time[c];
126 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex /w optimization iterations %i: %llu \n", c, exec_time[c]); 131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
127 } 132 "Simplex /w optimization iterations %i: %llu \n",
128 133 c, exec_time[c]);
129 glp_delete_prob(prob); 134 }
135
136 glp_delete_prob(prob);
130} 137}
131 138
132 139
133void bench_simplex_no_optimization(char * file, int executions) 140static void
141bench_simplex_no_optimization(char * file, int executions)
134{ 142{
135 143
136 int c; 144 int c;
137 prob = glp_create_prob(); 145 prob = glp_create_prob();
138 glp_read_lp(prob, NULL, file); 146 glp_read_lp(prob, NULL, file);
139 147
140 for (c=0; c<executions;c++) 148 for (c=0; c<executions;c++)
141 { 149 {
142 start = GNUNET_TIME_absolute_get(); 150 start = GNUNET_TIME_absolute_get();
143 solve_lp(GNUNET_YES); 151 solve_lp(GNUNET_YES);
144 end = GNUNET_TIME_absolute_get(); 152 end = GNUNET_TIME_absolute_get();
145 153
146 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 154 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
147 155
148 sim_no_opt_avg += exec_time[c]; 156 sim_no_opt_avg += exec_time[c];
149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex iterations %i: %llu \n", c, exec_time[c]); 157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
150 } 158 "Simplex iterations %i: %llu \n",
151 159 c, exec_time[c]);
152 glp_delete_prob(prob); 160 }
161
162 glp_delete_prob(prob);
153} 163}
154 164
155void bench_mlp_no_optimization(char * file, int executions)
156{
157
158 int c;
159 prob = glp_create_prob();
160 glp_read_lp(prob, NULL, file);
161
162 for (c=0; c<executions;c++)
163 {
164 start = GNUNET_TIME_absolute_get();
165 solve_lp(GNUNET_YES);
166 solve_mlp (GNUNET_NO);
167 end = GNUNET_TIME_absolute_get();
168
169 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
170
171 mlp_no_opt_avg += exec_time[c];
172 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP iterations no optimization %i: %llu \n", c, exec_time[c]);
173 }
174 165
175 glp_delete_prob(prob); 166static void
167bench_mlp_no_optimization(char * file, int executions)
168{
169
170 int c;
171 prob = glp_create_prob();
172 glp_read_lp(prob, NULL, file);
173
174 for (c=0; c<executions;c++)
175 {
176 start = GNUNET_TIME_absolute_get();
177 solve_lp(GNUNET_YES);
178 solve_mlp (GNUNET_NO);
179 end = GNUNET_TIME_absolute_get();
180
181 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
182
183 mlp_no_opt_avg += exec_time[c];
184 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP iterations no optimization %i: %llu \n", c, exec_time[c]);
185 }
186
187 glp_delete_prob(prob);
176} 188}
177 189
178 190
179void bench_mlp_with_optimization(char * file, int executions, int changes) 191static void
192bench_mlp_with_optimization(char * file, int executions, int changes)
180{ 193{
181 int c; 194 int c;
182 prob = glp_create_prob(); 195 prob = glp_create_prob();
183 glp_read_lp(prob, NULL, file); 196 glp_read_lp(prob, NULL, file);
184 197
185 solve_lp(GNUNET_YES); 198 solve_lp(GNUNET_YES);
186 199
187 for (c=0; c<executions;c++) 200 for (c=0; c<executions;c++)
188 { 201 {
189 start = GNUNET_TIME_absolute_get(); 202 start = GNUNET_TIME_absolute_get();
190 //modify_qm(906, 0, 0); 203 // modify_qm(906, 0, 0);
191 solve_lp(GNUNET_NO); 204 solve_lp(GNUNET_NO);
192 solve_mlp (GNUNET_NO); 205 solve_mlp (GNUNET_NO);
193 end = GNUNET_TIME_absolute_get(); 206 end = GNUNET_TIME_absolute_get();
194 207
195 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; 208 exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value;
196 209
197 mlp_with_opt_avg += exec_time[c]; 210 mlp_with_opt_avg += exec_time[c];
198 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP /w optimization iterations %i: %llu \n", c, exec_time[c]); 211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP /w optimization iterations %i: %llu \n", c, exec_time[c]);
199 } 212 }
200 213
201 glp_delete_prob(prob); 214 glp_delete_prob(prob);
202} 215}
203 216
204#if 0 217#if 0
205void modify_cr (int start, int length, int count) 218static void
219modify_cr (int start, int length, int count)
206{ 220{
207 //int * ind = GNUNET_malloc (length * sizeof (int)); 221 //int * ind = GNUNET_malloc (length * sizeof (int));
208 //double *val = GNUNET_malloc (length * sizeof (double)); 222 //double *val = GNUNET_malloc (length * sizeof (double));
209 int ind[500]; 223 int ind[500];
210 double val[500]; 224 double val[500];
211 int res = 0; 225 int res = 0;
212 int c = start, c2=1; 226 int c = start, c2=1;
213 while (c<=(start+count)) 227 while (c<=(start+count))
228 {
229 res = glp_get_mat_row(prob, c, ind, val);
230
231 printf("row index: %i non-zero elements: %i \n", c, res);
232 for (c2=1; c2<=res; c2++)
214 { 233 {
215 res = glp_get_mat_row(prob, c, ind, val); 234 printf("%i = %f ", ind[c2], val[c2]);
216
217 printf("row index: %i non-zero elements: %i \n", c, res);
218 for (c2=1; c2<=res; c2++)
219 {
220 printf("%i = %f ", ind[c2], val[c2]);
221 }
222 c++;
223 printf ("\n----\n");
224 } 235 }
225 //glp_set_mat_row(prob, start, length, ind, val); 236 c++;
237 printf ("\n----\n");
238 }
239 //glp_set_mat_row(prob, start, length, ind, val);
226} 240}
227#endif 241#endif
228#endif 242#endif
229 243
230int main (int argc, char *argv[]) 244
245int
246main (int argc, char *argv[])
231{ 247{
232 int ret = 0; 248 int ret = 0;
233 GNUNET_log_setup ("perf-transport-ats", 249 GNUNET_log_setup ("perf-transport-ats",
234#if VERBOSE 250#if VERBOSE
235 "DEBUG", 251 "DEBUG",
236#else 252#else
237 "INFO", 253 "INFO",
238#endif 254#endif
239 NULL); 255 NULL);
240 256
241#if !HAVE_LIBGLPK 257#if !HAVE_LIBGLPK
242 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, exiting testcase\n"); 258 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
243 return 0; 259 "GLPK not installed, exiting testcase\n");
260 return 0;
244#else 261#else
245 262
246 char * file = "ats_mlp_p100_m400.problem"; 263 char * file = "ats_mlp_p100_m400.problem";
247 // char * file = "mlps/ats_mlp_p500_m2000.problem"; 264 // char * file = "mlps/ats_mlp_p500_m2000.problem";
248 bench_simplex_no_optimization (file, executions); 265 bench_simplex_no_optimization (file, executions);
249 bench_simplex_optimization (file, executions); 266 bench_simplex_optimization (file, executions);
250 bench_mlp_no_optimization (file, executions); 267 bench_mlp_no_optimization (file, executions);
251 bench_mlp_with_optimization (file, executions, 0); 268 bench_mlp_with_optimization (file, executions, 0);
252 269
253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex no optimization average: %llu\n", sim_no_opt_avg / EXECS); 270 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
271 "Simplex no optimization average: %llu\n",
272 sim_no_opt_avg / EXECS);
254 // -> 400 addresses 273 // -> 400 addresses
255 GAUGER ("TRANSPORT","GLPK simplex no optimization", (sim_no_opt_avg / EXECS) / 400, "ms/address"); 274 GAUGER ("GLPK",
256 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex, no optimization, average per peer: %llu\n", (sim_with_opt_avg / EXECS) / 400); 275 "GLPK simplex no optimization",
257 GAUGER ("TRANSPORT","GLPK simplex, 100 peers 400 addresses with optimization", (sim_with_opt_avg / EXECS) / 400, "ms/address"); 276 (sim_no_opt_avg / EXECS) / 400,
258 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP no optimization average: %llu\n", (mlp_no_opt_avg / EXECS) / 400); 277 "ms/address");
259 GAUGER ("TRANSPORT","GLPK MLP 100 peers 400 addresses no optimization", (mlp_no_opt_avg / EXECS) / 400, "ms/address"); 278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
260 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP optimization average: %llu\n", (mlp_with_opt_avg/ EXECS) / 400); 279 "Simplex, no optimization, average per peer: %llu\n",
261 GAUGER ("TRANSPORT","GLPK MLP 100 peers 400 addresses with optimization", (mlp_with_opt_avg / EXECS) / 400, "ms/address"); 280 (sim_with_opt_avg / EXECS) / 400);
281 GAUGER ("GLPK",
282 "GLPK simplex with optimization",
283 (sim_with_opt_avg / EXECS) / 400,
284 "ms/address");
285 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
286 "MLP no optimization average: %llu\n",
287 (mlp_no_opt_avg / EXECS) / 400);
288 GAUGER ("GLPK",
289 "GLPK MLP no optimization",
290 (mlp_no_opt_avg / EXECS) / 400,
291 "ms/address");
292 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP optimization average: %llu\n",
293 (mlp_with_opt_avg/ EXECS) / 400);
294 GAUGER ("GLPK",
295 "GLPK MLP with optimization",
296 (mlp_with_opt_avg / EXECS) / 400, "ms/address");
262 297
263#endif 298#endif
264 return ret; 299 return ret;