diff options
-rw-r--r-- | src/transport/test_transport_ats_perf.c | 97 |
1 files changed, 39 insertions, 58 deletions
diff --git a/src/transport/test_transport_ats_perf.c b/src/transport/test_transport_ats_perf.c index 51828bcdd..0b0c3634e 100644 --- a/src/transport/test_transport_ats_perf.c +++ b/src/transport/test_transport_ats_perf.c | |||
@@ -26,12 +26,12 @@ | |||
26 | #include "gauger.h" | 26 | #include "gauger.h" |
27 | #include <glpk.h> | 27 | #include <glpk.h> |
28 | 28 | ||
29 | #define VERBOSE GNUNET_NO | 29 | #define VERBOSE GNUNET_YES |
30 | 30 | ||
31 | #define EXECS 5 | 31 | #define EXECS 5 |
32 | 32 | ||
33 | 33 | ||
34 | 34 | #if HAVE_LIBGLPK | |
35 | static int executions = EXECS; | 35 | static int executions = EXECS; |
36 | static uint64_t exec_time[EXECS]; | 36 | static uint64_t exec_time[EXECS]; |
37 | 37 | ||
@@ -40,8 +40,6 @@ static uint64_t sim_with_opt_avg; | |||
40 | static uint64_t mlp_no_opt_avg; | 40 | static uint64_t mlp_no_opt_avg; |
41 | static uint64_t mlp_with_opt_avg; | 41 | static uint64_t mlp_with_opt_avg; |
42 | 42 | ||
43 | #if HAVE_LIBGLPK | ||
44 | |||
45 | static glp_prob * prob; | 43 | static glp_prob * prob; |
46 | 44 | ||
47 | static struct GNUNET_TIME_Absolute start; | 45 | static struct GNUNET_TIME_Absolute start; |
@@ -55,6 +53,7 @@ void solve_mlp(int presolve) | |||
55 | glp_iocp opt_mlp; | 53 | glp_iocp opt_mlp; |
56 | glp_init_iocp(&opt_mlp); | 54 | glp_init_iocp(&opt_mlp); |
57 | opt_mlp.msg_lev = GLP_MSG_OFF; | 55 | opt_mlp.msg_lev = GLP_MSG_OFF; |
56 | opt_mlp.presolve = GLP_OFF; | ||
58 | 57 | ||
59 | result = glp_intopt (prob, &opt_mlp); | 58 | result = glp_intopt (prob, &opt_mlp); |
60 | solution = glp_mip_status (prob); | 59 | solution = glp_mip_status (prob); |
@@ -70,12 +69,39 @@ void solve_lp(int presolve) | |||
70 | 69 | ||
71 | opt_lp.msg_lev = GLP_MSG_OFF; | 70 | opt_lp.msg_lev = GLP_MSG_OFF; |
72 | if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON; | 71 | if (presolve==GNUNET_YES) opt_lp.presolve = GLP_ON; |
72 | else opt_lp.presolve = GLP_OFF; | ||
73 | 73 | ||
74 | result = glp_simplex(prob, &opt_lp); | 74 | result = glp_simplex(prob, &opt_lp); |
75 | solution = glp_get_status (prob); | 75 | solution = glp_get_status (prob); |
76 | GNUNET_assert ((solution == 5) && (result==0)); | 76 | GNUNET_assert ((solution == 5) && (result==0)); |
77 | } | 77 | } |
78 | 78 | ||
79 | /* Modify quality constraint */ | ||
80 | void modify_qm(int start, int length, int values_to_change) | ||
81 | { | ||
82 | //int * ind = GNUNET_malloc (length * sizeof (int)); | ||
83 | //double *val = GNUNET_malloc (length * sizeof (double)); | ||
84 | int ind[1000]; | ||
85 | double val[1000]; | ||
86 | |||
87 | int res = 0; | ||
88 | int c = start, c2=1; | ||
89 | while (c<=(start+values_to_change)) | ||
90 | { | ||
91 | res = glp_get_mat_row(prob, c, ind, val); | ||
92 | |||
93 | printf("%i %i \n", c, res); | ||
94 | for (c2=0; c2<res; c2++) | ||
95 | { | ||
96 | printf("%i = %f \n", ind[c2], val[c2]); | ||
97 | } | ||
98 | |||
99 | c++; | ||
100 | } | ||
101 | //glp_set_mat_row(prob, start, length, ind, val); | ||
102 | } | ||
103 | |||
104 | |||
79 | 105 | ||
80 | void bench_simplex_optimization(char * file, int executions) | 106 | void bench_simplex_optimization(char * file, int executions) |
81 | { | 107 | { |
@@ -148,7 +174,7 @@ void bench_mlp_no_optimization(char * file, int executions) | |||
148 | } | 174 | } |
149 | 175 | ||
150 | 176 | ||
151 | void bench_mlp_with_optimization(char * file, int executions) | 177 | void bench_mlp_with_optimization(char * file, int executions, int changes) |
152 | { | 178 | { |
153 | int c; | 179 | int c; |
154 | prob = glp_create_prob(); | 180 | prob = glp_create_prob(); |
@@ -159,6 +185,7 @@ void bench_mlp_with_optimization(char * file, int executions) | |||
159 | for (c=0; c<executions;c++) | 185 | for (c=0; c<executions;c++) |
160 | { | 186 | { |
161 | start = GNUNET_TIME_absolute_get(); | 187 | start = GNUNET_TIME_absolute_get(); |
188 | //modify_qm(906, 0, 0); | ||
162 | solve_lp(GNUNET_NO); | 189 | solve_lp(GNUNET_NO); |
163 | solve_mlp (GNUNET_NO); | 190 | solve_mlp (GNUNET_NO); |
164 | end = GNUNET_TIME_absolute_get(); | 191 | end = GNUNET_TIME_absolute_get(); |
@@ -172,31 +199,7 @@ void bench_mlp_with_optimization(char * file, int executions) | |||
172 | glp_delete_prob(prob); | 199 | glp_delete_prob(prob); |
173 | } | 200 | } |
174 | 201 | ||
175 | /* Modify quality constraint */ | 202 | #if 0 |
176 | void modify_qm(int start, int length, int count) | ||
177 | { | ||
178 | //int * ind = GNUNET_malloc (length * sizeof (int)); | ||
179 | //double *val = GNUNET_malloc (length * sizeof (double)); | ||
180 | int ind[1000]; | ||
181 | double val[1000]; | ||
182 | |||
183 | int res = 0; | ||
184 | int c = start, c2=1; | ||
185 | while (c<=(start+count)) | ||
186 | { | ||
187 | res = glp_get_mat_row(prob, c, ind, val); | ||
188 | |||
189 | printf("%i %i \n", c, res); | ||
190 | for (c2=0; c2<res; c2++) | ||
191 | { | ||
192 | printf("%i = %f \n", ind[c2], val[c2]); | ||
193 | } | ||
194 | |||
195 | c++; | ||
196 | } | ||
197 | //glp_set_mat_row(prob, start, length, ind, val); | ||
198 | } | ||
199 | |||
200 | void modify_cr (int start, int length, int count) | 203 | void modify_cr (int start, int length, int count) |
201 | { | 204 | { |
202 | //int * ind = GNUNET_malloc (length * sizeof (int)); | 205 | //int * ind = GNUNET_malloc (length * sizeof (int)); |
@@ -219,35 +222,13 @@ void modify_cr (int start, int length, int count) | |||
219 | } | 222 | } |
220 | //glp_set_mat_row(prob, start, length, ind, val); | 223 | //glp_set_mat_row(prob, start, length, ind, val); |
221 | } | 224 | } |
222 | /* | ||
223 | void test_mlp(char * file) | ||
224 | { | ||
225 | int c =0; | ||
226 | prob = glp_create_prob(); | ||
227 | glp_read_lp(prob, NULL, file); | ||
228 | #if VERBOSE | ||
229 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%i iterations simplex, presolve: YES, keep problem: YES!\n", executions, exec_time[c]); | ||
230 | #endif | 225 | #endif |
231 | |||
232 | mlp_w_ps_w_keep_avg = 0; | ||
233 | for (c=0; c<executions;c++) | ||
234 | { | ||
235 | start = GNUNET_TIME_absolute_get(); | ||
236 | solve_mlp(GNUNET_NO); | ||
237 | //modify_qm (906,10,2); | ||
238 | modify_cr (901,10,3); | ||
239 | end = GNUNET_TIME_absolute_get(); | ||
240 | |||
241 | exec_time[c] = GNUNET_TIME_absolute_get_difference(start, end).rel_value; | ||
242 | mlp_wo_ps_w_keep_avg += exec_time[c]; | ||
243 | } | ||
244 | }*/ | ||
245 | |||
246 | #endif | 226 | #endif |
247 | 227 | ||
248 | int main (int argc, char *argv[]) | 228 | int main (int argc, char *argv[]) |
249 | { | 229 | { |
250 | GNUNET_log_setup ("test-transport-ats", | 230 | int ret = 0; |
231 | GNUNET_log_setup ("test-transport-ats", | ||
251 | #if VERBOSE | 232 | #if VERBOSE |
252 | "DEBUG", | 233 | "DEBUG", |
253 | #else | 234 | #else |
@@ -258,15 +239,14 @@ int main (int argc, char *argv[]) | |||
258 | #if !HAVE_LIBGLPK | 239 | #if !HAVE_LIBGLPK |
259 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, exiting testcase\n"); | 240 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed, exiting testcase\n"); |
260 | return 0; | 241 | return 0; |
261 | #endif | 242 | #else |
262 | |||
263 | int ret = 0; | ||
264 | 243 | ||
265 | char * file = "ats_mlp_p100_m400.problem"; | 244 | char * file = "ats_mlp_p100_m400.problem"; |
245 | // char * file = "mlps/ats_mlp_p500_m2000.problem"; | ||
266 | bench_simplex_no_optimization (file, executions); | 246 | bench_simplex_no_optimization (file, executions); |
267 | bench_simplex_optimization (file, executions); | 247 | bench_simplex_optimization (file, executions); |
268 | bench_mlp_no_optimization (file, executions); | 248 | bench_mlp_no_optimization (file, executions); |
269 | bench_mlp_with_optimization (file, executions); | 249 | bench_mlp_with_optimization (file, executions, 0); |
270 | 250 | ||
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex no optimization average: %llu\n", sim_no_opt_avg / EXECS); | 251 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Simplex no optimization average: %llu\n", sim_no_opt_avg / EXECS); |
272 | GAUGER ("TRANSPORT","GLPK simplex 100 peers 400 addresses no optimization", sim_no_opt_avg / EXECS, "ms"); | 252 | GAUGER ("TRANSPORT","GLPK simplex 100 peers 400 addresses no optimization", sim_no_opt_avg / EXECS, "ms"); |
@@ -277,6 +257,7 @@ int main (int argc, char *argv[]) | |||
277 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP optimization average: %llu\n", mlp_with_opt_avg / EXECS); | 257 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP optimization average: %llu\n", mlp_with_opt_avg / EXECS); |
278 | GAUGER ("TRANSPORT","GLPK MLP 100 peers 400 addresses with optimization", mlp_with_opt_avg / EXECS, "ms"); | 258 | GAUGER ("TRANSPORT","GLPK MLP 100 peers 400 addresses with optimization", mlp_with_opt_avg / EXECS, "ms"); |
279 | 259 | ||
260 | #endif | ||
280 | return ret; | 261 | return ret; |
281 | } | 262 | } |
282 | 263 | ||