diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-20 12:57:14 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-20 12:57:14 +0000 |
commit | 46ddbf03b6c4b5667c92b0778d675e306ff0e88e (patch) | |
tree | e97fa524326c1cd53f11d1bec9bb94790f30c455 | |
parent | aae28d3ce34db58c33987f7b3d36de079d83994a (diff) | |
download | gnunet-46ddbf03b6c4b5667c92b0778d675e306ff0e88e.tar.gz gnunet-46ddbf03b6c4b5667c92b0778d675e306ff0e88e.zip |
simplify code, run longer
-rw-r--r-- | src/core/test_core_api.c | 2 | ||||
-rw-r--r-- | src/core/test_core_api_reliability.c | 2 | ||||
-rw-r--r-- | src/core/test_core_quota_compliance.c | 84 |
3 files changed, 44 insertions, 44 deletions
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index 10cba9d8a..56b7412c3 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c | |||
@@ -62,7 +62,7 @@ static GNUNET_SCHEDULER_TaskIdentifier con_task; | |||
62 | static int ok; | 62 | static int ok; |
63 | 63 | ||
64 | #if VERBOSE | 64 | #if VERBOSE |
65 | #define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) | 65 | #define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) |
66 | #else | 66 | #else |
67 | #define OKPP do { ok++; } while (0) | 67 | #define OKPP do { ok++; } while (0) |
68 | #endif | 68 | #endif |
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index a55409e69..f40b61660 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c | |||
@@ -90,7 +90,7 @@ static int32_t tr_n; | |||
90 | 90 | ||
91 | 91 | ||
92 | #if VERBOSE | 92 | #if VERBOSE |
93 | #define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) | 93 | #define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) |
94 | #else | 94 | #else |
95 | #define OKPP do { ok++; } while (0) | 95 | #define OKPP do { ok++; } while (0) |
96 | #endif | 96 | #endif |
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index c543f09cd..2a7c7f8f6 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c | |||
@@ -61,7 +61,7 @@ | |||
61 | 61 | ||
62 | #define MTYPE 12345 | 62 | #define MTYPE 12345 |
63 | #define MESSAGESIZE 1024 | 63 | #define MESSAGESIZE 1024 |
64 | #define MEASUREMENT_LENGTH GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 64 | #define MEASUREMENT_LENGTH GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
65 | 65 | ||
66 | static unsigned long long total_bytes_sent; | 66 | static unsigned long long total_bytes_sent; |
67 | static unsigned long long total_bytes_recv; | 67 | static unsigned long long total_bytes_recv; |
@@ -107,7 +107,7 @@ static int running; | |||
107 | 107 | ||
108 | 108 | ||
109 | #if VERBOSE | 109 | #if VERBOSE |
110 | #define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) | 110 | #define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) |
111 | #else | 111 | #else |
112 | #define OKPP do { ok++; } while (0) | 112 | #define OKPP do { ok++; } while (0) |
113 | #endif | 113 | #endif |
@@ -217,12 +217,13 @@ print_stat (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
217 | static void | 217 | static void |
218 | measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 218 | measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
219 | { | 219 | { |
220 | unsigned long long int delta; | 220 | unsigned long long delta; |
221 | unsigned long long int throughput_out; | 221 | unsigned long long throughput_out; |
222 | unsigned long long int throughput_in; | 222 | unsigned long long throughput_in; |
223 | unsigned long long int max_quota_in; | 223 | unsigned long long max_quota_in; |
224 | unsigned long long int max_quota_out; | 224 | unsigned long long max_quota_out; |
225 | unsigned long long int quota_delta; | 225 | unsigned long long quota_delta; |
226 | enum GNUNET_ErrorType kind = GNUNET_ERROR_TYPE_DEBUG; | ||
226 | 227 | ||
227 | measure_task = GNUNET_SCHEDULER_NO_TASK; | 228 | measure_task = GNUNET_SCHEDULER_NO_TASK; |
228 | fprintf (stdout, "\n"); | 229 | fprintf (stdout, "\n"); |
@@ -230,29 +231,25 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
230 | 231 | ||
231 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; | 232 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value; |
232 | 233 | ||
233 | throughput_out = total_bytes_sent * 1000 / 1024 / delta; | 234 | throughput_out = total_bytes_sent * 1000 / delta; /* convert to bytes/s */ |
234 | throughput_in = total_bytes_recv * 1000 / 1024 / delta; | 235 | throughput_in = total_bytes_recv * 1000 / delta; /* convert to bytes/s */ |
235 | 236 | ||
236 | if (current_quota_p1_in < current_quota_p2_in) | 237 | max_quota_in = GNUNET_MIN (current_quota_p1_in, |
237 | max_quota_in = current_quota_p1_in; | 238 | current_quota_p2_in); |
238 | else | 239 | max_quota_out = GNUNET_MIN (current_quota_p1_out, |
239 | max_quota_in = current_quota_p2_in; | 240 | current_quota_p2_out); |
240 | if (current_quota_p1_out < current_quota_p2_out) | ||
241 | max_quota_out = current_quota_p1_out; | ||
242 | else | ||
243 | max_quota_out = current_quota_p2_out; | ||
244 | 241 | ||
242 | max_quota_out /= 2; | ||
245 | if (max_quota_out < max_quota_in) | 243 | if (max_quota_out < max_quota_in) |
246 | quota_delta = max_quota_in / 10; | 244 | quota_delta = max_quota_in / 10; |
247 | else | 245 | else |
248 | quota_delta = max_quota_out / 10; | 246 | quota_delta = max_quota_out / 10; |
249 | 247 | ||
250 | if ((throughput_out > (max_quota_out + quota_delta) / 1024) || | 248 | if ((throughput_out > (max_quota_out + quota_delta)) || |
251 | (throughput_in > (max_quota_in + quota_delta) / 1024)) | 249 | (throughput_in > (max_quota_in + quota_delta))) |
252 | ok = 1; | 250 | ok = GNUNET_NO; |
253 | else | 251 | else |
254 | ok = 0; | 252 | ok = GNUNET_YES; |
255 | |||
256 | GNUNET_STATISTICS_get (p1.stats, "core", "# discarded CORE_SEND requests", | 253 | GNUNET_STATISTICS_get (p1.stats, "core", "# discarded CORE_SEND requests", |
257 | GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p1); | 254 | GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p1); |
258 | 255 | ||
@@ -278,40 +275,36 @@ measurement_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
278 | "# discarded lower priority CORE_SEND request bytes", | 275 | "# discarded lower priority CORE_SEND request bytes", |
279 | GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p2); | 276 | GNUNET_TIME_UNIT_FOREVER_REL, NULL, &print_stat, &p2); |
280 | 277 | ||
281 | enum GNUNET_ErrorType kind = GNUNET_ERROR_TYPE_DEBUG; | 278 | if (ok == GNUNET_NO) |
282 | 279 | kind = GNUNET_ERROR_TYPE_ERROR; | |
283 | if (ok == 1) | ||
284 | { | ||
285 | kind = GNUNET_ERROR_TYPE_ERROR; | ||
286 | } | ||
287 | switch (test) | 280 | switch (test) |
288 | { | 281 | { |
289 | case SYMMETRIC: | 282 | case SYMMETRIC: |
290 | GNUNET_log (kind, "Core quota compliance test with symmetric quotas: %s\n", | 283 | GNUNET_log (kind, "Core quota compliance test with symmetric quotas: %s\n", |
291 | (ok == 0) ? "PASSED" : "FAILED"); | 284 | (ok == GNUNET_YES) ? "PASSED" : "FAILED"); |
292 | break; | 285 | break; |
293 | case ASYMMETRIC_SEND_LIMITED: | 286 | case ASYMMETRIC_SEND_LIMITED: |
294 | GNUNET_log (kind, | 287 | GNUNET_log (kind, |
295 | "Core quota compliance test with limited sender quota: %s\n", | 288 | "Core quota compliance test with limited sender quota: %s\n", |
296 | (ok == 0) ? "PASSED" : "FAILED"); | 289 | (ok == GNUNET_YES) ? "PASSED" : "FAILED"); |
297 | break; | 290 | break; |
298 | case ASYMMETRIC_RECV_LIMITED: | 291 | case ASYMMETRIC_RECV_LIMITED: |
299 | GNUNET_log (kind, | 292 | GNUNET_log (kind, |
300 | "Core quota compliance test with limited receiver quota: %s\n", | 293 | "Core quota compliance test with limited receiver quota: %s\n", |
301 | (ok == 0) ? "PASSED" : "FAILED"); | 294 | (ok == GNUNET_YES) ? "PASSED" : "FAILED"); |
302 | break; | 295 | break; |
303 | }; | 296 | }; |
304 | GNUNET_log (kind, "Peer 1 send rate: %llu kB/s (%llu Bytes in %u sec.)\n", | 297 | GNUNET_log (kind, "Peer 1 send rate: %llu b/s (%llu bytes in %llu ms)\n", |
305 | throughput_out, total_bytes_sent, delta / 1000); | 298 | throughput_out, total_bytes_sent, delta); |
306 | GNUNET_log (kind, "Peer 1 send quota: %llu kB/s\n", | 299 | GNUNET_log (kind, "Peer 1 send quota: %llu b/s\n", |
307 | current_quota_p1_out / 1024); | 300 | current_quota_p1_out); |
308 | GNUNET_log (kind, "Peer 2 receive rate: %llu kB/s (%llu Bytes in %u sec.)\n", | 301 | GNUNET_log (kind, "Peer 2 receive rate: %llu b/s (%llu bytes in %llu ms)\n", |
309 | throughput_in, total_bytes_recv, delta / 1000); | 302 | throughput_in, total_bytes_recv, delta); |
310 | GNUNET_log (kind, "Peer 2 receive quota: %llu kB/s\n", | 303 | GNUNET_log (kind, "Peer 2 receive quota: %llu b/s\n", |
311 | current_quota_p2_in / 1024); | 304 | current_quota_p2_in); |
312 | /* | 305 | /* |
313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu kB/s\n",max_quota_in /1024); | 306 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. inbound quota allowed: %llu b/s\n",max_quota_in ); |
314 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu kB/s\n",max_quota_out/1024); | 307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Max. outbound quota allowed: %llu b/s\n",max_quota_out); |
315 | */ | 308 | */ |
316 | GNUNET_SCHEDULER_cancel (err_task); | 309 | GNUNET_SCHEDULER_cancel (err_task); |
317 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task, NULL); | 310 | err_task = GNUNET_SCHEDULER_add_now (&terminate_task, NULL); |
@@ -418,6 +411,13 @@ disconnect_notify (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
418 | if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) | 411 | if (0 == memcmp (&pc->id, peer, sizeof (struct GNUNET_PeerIdentity))) |
419 | return; /* loopback */ | 412 | return; /* loopback */ |
420 | pc->connect_status = 0; | 413 | pc->connect_status = 0; |
414 | if (GNUNET_SCHEDULER_NO_TASK != measure_task) | ||
415 | { | ||
416 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
417 | "Measurement aborted due to disconnect!\n"); | ||
418 | GNUNET_SCHEDULER_cancel (measure_task); | ||
419 | measure_task = GNUNET_SCHEDULER_NO_TASK; | ||
420 | } | ||
421 | if (pc->nth != NULL) | 421 | if (pc->nth != NULL) |
422 | { | 422 | { |
423 | GNUNET_CORE_notify_transmit_ready_cancel (pc->nth); | 423 | GNUNET_CORE_notify_transmit_ready_cancel (pc->nth); |