diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-22 10:40:04 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-22 10:40:04 +0000 |
commit | 7c241d90b842906019706995a48ba93eaa7acb9e (patch) | |
tree | a81ada9bd8137347183306d9f57017c88a84a549 /src/ats-tests/perf_ats.c | |
parent | 611a4740a7425e70f073e8183f96d51fa065502d (diff) | |
download | gnunet-7c241d90b842906019706995a48ba93eaa7acb9e.tar.gz gnunet-7c241d90b842906019706995a48ba93eaa7acb9e.zip |
improvements
Diffstat (limited to 'src/ats-tests/perf_ats.c')
-rw-r--r-- | src/ats-tests/perf_ats.c | 87 |
1 files changed, 58 insertions, 29 deletions
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c index c79e291b8..53533a82a 100644 --- a/src/ats-tests/perf_ats.c +++ b/src/ats-tests/perf_ats.c | |||
@@ -40,7 +40,12 @@ | |||
40 | #define TEST_MESSAGE_SIZE 1000 | 40 | #define TEST_MESSAGE_SIZE 1000 |
41 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 41 | #define TEST_MESSAGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
42 | 42 | ||
43 | 43 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) | |
44 | #define BENCHMARK_DURATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | ||
45 | #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500) | ||
46 | #define TESTNAME_PREFIX "perf_ats_" | ||
47 | #define DEFAULT_SLAVES_NUM 2 | ||
48 | #define DEFAULT_MASTERS_NUM 1 | ||
44 | /** | 49 | /** |
45 | * Shutdown task | 50 | * Shutdown task |
46 | */ | 51 | */ |
@@ -124,6 +129,12 @@ evaluate () | |||
124 | struct BenchmarkPeer *mp; | 129 | struct BenchmarkPeer *mp; |
125 | struct BenchmarkPartner *p; | 130 | struct BenchmarkPartner *p; |
126 | 131 | ||
132 | unsigned int kb_sent_sec; | ||
133 | double kb_sent_percent; | ||
134 | unsigned int kb_recv_sec; | ||
135 | double kb_recv_percent; | ||
136 | unsigned int rtt; | ||
137 | |||
127 | duration = (perf_duration.rel_value_us / (1000 * 1000)); | 138 | duration = (perf_duration.rel_value_us / (1000 * 1000)); |
128 | for (c_m = 0; c_m < num_masters; c_m++) | 139 | for (c_m = 0; c_m < num_masters; c_m++) |
129 | { | 140 | { |
@@ -138,19 +149,35 @@ evaluate () | |||
138 | for (c_s = 0; c_s < num_slaves; c_s++) | 149 | for (c_s = 0; c_s < num_slaves; c_s++) |
139 | { | 150 | { |
140 | p = &mp->partners[c_s]; | 151 | p = &mp->partners[c_s]; |
152 | |||
153 | kb_sent_sec = 0; | ||
154 | kb_recv_sec = 0; | ||
155 | kb_sent_percent = 0.0; | ||
156 | kb_recv_percent = 0.0; | ||
157 | rtt = 0; | ||
158 | |||
159 | if (duration > 0) | ||
160 | { | ||
161 | kb_sent_percent = (p->bytes_sent / 1024) / duration; | ||
162 | kb_recv_percent = (p->bytes_received / 1024) / duration; | ||
163 | } | ||
164 | if (mp->total_bytes_sent > 0) | ||
165 | kb_sent_percent = ((double) p->bytes_sent * 100) / mp->total_bytes_sent; | ||
166 | if (mp->total_bytes_received > 0) | ||
167 | kb_recv_percent = ((double) p->bytes_received * 100) / mp->total_bytes_received; | ||
168 | if (1000 * p->messages_sent > 0) | ||
169 | rtt = p->total_app_rtt / (1000 * p->messages_sent); | ||
141 | fprintf (stderr, | 170 | fprintf (stderr, |
142 | "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n", | 171 | "%c Master [%u] -> Slave [%u]: sent %u KiB/s (%.2f %%), received %u KiB/s (%.2f %%)\n", |
143 | (mp->pref_partner == p->dest) ? '*' : ' ', | 172 | (mp->pref_partner == p->dest) ? '*' : ' ', |
144 | mp->no, p->dest->no, | 173 | mp->no, p->dest->no, |
145 | (p->bytes_sent / 1024) / duration, | 174 | kb_sent_sec, kb_sent_percent, |
146 | ((double) p->bytes_sent * 100) / mp->total_bytes_sent, | 175 | kb_recv_sec, kb_recv_percent); |
147 | (p->bytes_received / 1024) / duration, | 176 | |
148 | ((double) p->bytes_received * 100) / mp->total_bytes_received ); | ||
149 | fprintf (stderr, | 177 | fprintf (stderr, |
150 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", | 178 | "%c Master [%u] -> Slave [%u]: Average application layer RTT: %u ms\n", |
151 | (mp->pref_partner == p->dest) ? '*' : ' ', | 179 | (mp->pref_partner == p->dest) ? '*' : ' ', |
152 | mp->no, p->dest->no, | 180 | mp->no, p->dest->no, rtt); |
153 | p->total_app_rtt / (1000 * p->messages_sent)); | ||
154 | } | 181 | } |
155 | } | 182 | } |
156 | } | 183 | } |
@@ -164,10 +191,10 @@ evaluate () | |||
164 | static void | 191 | static void |
165 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 192 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
166 | { | 193 | { |
167 | /* | 194 | |
168 | if (GNUNET_YES == logging) | 195 | if (GNUNET_YES == logging) |
169 | perf_logging_stop(); | 196 | GNUNET_ATS_TEST_logging_stop(); |
170 | */ | 197 | |
171 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | 198 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; |
172 | if (GNUNET_SCHEDULER_NO_TASK != progress_task) | 199 | if (GNUNET_SCHEDULER_NO_TASK != progress_task) |
173 | { | 200 | { |
@@ -300,10 +327,8 @@ do_benchmark (void *cls, struct BenchmarkPeer *masters, struct BenchmarkPeer *sl | |||
300 | masters[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, &masters[c_m]); | 327 | masters[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, &masters[c_m]); |
301 | } | 328 | } |
302 | 329 | ||
303 | /* | ||
304 | if (GNUNET_YES == logging) | 330 | if (GNUNET_YES == logging) |
305 | perf_logging_start (log_frequency, testname, mps, num_masters); | 331 | GNUNET_ATS_TEST_logging_start (log_frequency, testname, mps, num_masters); |
306 | */ | ||
307 | } | 332 | } |
308 | 333 | ||
309 | 334 | ||
@@ -349,7 +374,6 @@ find_partner (struct BenchmarkPeer *me, const struct GNUNET_PeerIdentity * peer) | |||
349 | return &me->partners[c_m]; | 374 | return &me->partners[c_m]; |
350 | } | 375 | } |
351 | } | 376 | } |
352 | |||
353 | return NULL; | 377 | return NULL; |
354 | } | 378 | } |
355 | 379 | ||
@@ -422,11 +446,10 @@ comm_handle_pong (void *cls, const struct GNUNET_PeerIdentity *other, | |||
422 | } | 446 | } |
423 | 447 | ||
424 | 448 | ||
425 | |||
426 | static void | 449 | static void |
427 | transport_recv_cb (void *cls, | 450 | test_recv_cb (void *cls, |
428 | const struct GNUNET_PeerIdentity * peer, | 451 | const struct GNUNET_PeerIdentity * peer, |
429 | const struct GNUNET_MessageHeader * message) | 452 | const struct GNUNET_MessageHeader * message) |
430 | { | 453 | { |
431 | if (TEST_MESSAGE_SIZE != ntohs (message->size) || | 454 | if (TEST_MESSAGE_SIZE != ntohs (message->size) || |
432 | (TEST_MESSAGE_TYPE_PING != ntohs (message->type) && | 455 | (TEST_MESSAGE_TYPE_PING != ntohs (message->type) && |
@@ -442,9 +465,6 @@ transport_recv_cb (void *cls, | |||
442 | } | 465 | } |
443 | 466 | ||
444 | 467 | ||
445 | |||
446 | |||
447 | |||
448 | static void | 468 | static void |
449 | ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address, | 469 | ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address, |
450 | int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 470 | int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
@@ -532,17 +552,17 @@ ats_performance_info_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
532 | break; | 552 | break; |
533 | } | 553 | } |
534 | } | 554 | } |
535 | /* | 555 | |
536 | if ((GNUNET_YES == logging) && (GNUNET_YES == log)) | 556 | if ((GNUNET_YES == logging) && (GNUNET_YES == log)) |
537 | collect_log_now(); | 557 | GNUNET_ATS_TEST_logging_now(); |
538 | */ | 558 | |
539 | GNUNET_free(peer_id); | 559 | GNUNET_free(peer_id); |
540 | } | 560 | } |
541 | 561 | ||
542 | 562 | ||
543 | 563 | /* | |
544 | 564 | * Start the performance test case | |
545 | 565 | */ | |
546 | int | 566 | int |
547 | main (int argc, char *argv[]) | 567 | main (int argc, char *argv[]) |
548 | { | 568 | { |
@@ -720,14 +740,23 @@ main (int argc, char *argv[]) | |||
720 | return GNUNET_SYSERR; | 740 | return GNUNET_SYSERR; |
721 | } | 741 | } |
722 | 742 | ||
743 | /** | ||
744 | * Core message handler to use for PING/PONG messages | ||
745 | */ | ||
723 | static struct GNUNET_CORE_MessageHandler handlers[] = { | 746 | static struct GNUNET_CORE_MessageHandler handlers[] = { |
724 | {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, | 747 | {&comm_handle_ping, TEST_MESSAGE_TYPE_PING, 0 }, |
725 | {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 }, | 748 | {&comm_handle_pong, TEST_MESSAGE_TYPE_PONG, 0 }, |
726 | { NULL, 0, 0 } }; | 749 | { NULL, 0, 0 } }; |
727 | 750 | ||
751 | /** | ||
752 | * Setup the topology | ||
753 | */ | ||
728 | GNUNET_ATS_TEST_create_topology ("perf-ats", conf_name, | 754 | GNUNET_ATS_TEST_create_topology ("perf-ats", conf_name, |
729 | num_slaves, num_masters, test_core, | 755 | num_slaves, num_masters, |
730 | &do_benchmark, NULL, handlers, &transport_recv_cb, | 756 | test_core, |
757 | &do_benchmark, | ||
758 | NULL, handlers, | ||
759 | &test_recv_cb, | ||
731 | &ats_performance_info_cb); | 760 | &ats_performance_info_cb); |
732 | 761 | ||
733 | return result; | 762 | return result; |