diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-09-18 15:38:21 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-09-18 15:38:21 +0000 |
commit | 25561d6f4418a6a1be71228ecce6a7739bd98148 (patch) | |
tree | f15520c0fc5d4ad5f5f66b42808560d73cf1228b | |
parent | 6541a98b8584ef585b56f89a080495ed4f476209 (diff) | |
download | gnunet-25561d6f4418a6a1be71228ecce6a7739bd98148.tar.gz gnunet-25561d6f4418a6a1be71228ecce6a7739bd98148.zip |
logging for master
-rw-r--r-- | src/ats-tests/perf_ats.c | 5 | ||||
-rw-r--r-- | src/ats-tests/perf_ats_logging.c | 67 |
2 files changed, 62 insertions, 10 deletions
diff --git a/src/ats-tests/perf_ats.c b/src/ats-tests/perf_ats.c index bad7076ca..67ff7d0af 100644 --- a/src/ats-tests/perf_ats.c +++ b/src/ats-tests/perf_ats.c | |||
@@ -437,6 +437,8 @@ do_benchmark () | |||
437 | progress_task = GNUNET_SCHEDULER_add_now (&print_progress, NULL ); | 437 | progress_task = GNUNET_SCHEDULER_add_now (&print_progress, NULL ); |
438 | 438 | ||
439 | /* Start sending test messages */ | 439 | /* Start sending test messages */ |
440 | if (GNUNET_YES == logging) | ||
441 | perf_logging_start (testname, mps, num_masters); | ||
440 | for (c_m = 0; c_m < num_masters; c_m++) | 442 | for (c_m = 0; c_m < num_masters; c_m++) |
441 | { | 443 | { |
442 | for (c_s = 0; c_s < num_slaves; c_s++) | 444 | for (c_s = 0; c_s < num_slaves; c_s++) |
@@ -455,8 +457,7 @@ do_benchmark () | |||
455 | if (pref_val != GNUNET_ATS_PREFERENCE_END) | 457 | if (pref_val != GNUNET_ATS_PREFERENCE_END) |
456 | mps[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, &mps[c_m]); | 458 | mps[c_m].ats_task = GNUNET_SCHEDULER_add_now (&ats_pref_task, &mps[c_m]); |
457 | } | 459 | } |
458 | if (GNUNET_YES == logging) | 460 | |
459 | perf_logging_start (testname, mps, num_masters); | ||
460 | } | 461 | } |
461 | 462 | ||
462 | static void | 463 | static void |
diff --git a/src/ats-tests/perf_ats_logging.c b/src/ats-tests/perf_ats_logging.c index b97b97533..51c09c266 100644 --- a/src/ats-tests/perf_ats_logging.c +++ b/src/ats-tests/perf_ats_logging.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "perf_ats.h" | 28 | #include "perf_ats.h" |
29 | 29 | ||
30 | #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500) | 30 | #define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100) |
31 | 31 | ||
32 | static GNUNET_SCHEDULER_TaskIdentifier log_task; | 32 | static GNUNET_SCHEDULER_TaskIdentifier log_task; |
33 | 33 | ||
@@ -37,10 +37,30 @@ static char *name; | |||
37 | 37 | ||
38 | struct LoggingTimestep | 38 | struct LoggingTimestep |
39 | { | 39 | { |
40 | struct GNUNET_TIME_Absolute timestamp; | ||
41 | |||
42 | struct LoggingTimestep *next; | 40 | struct LoggingTimestep *next; |
43 | struct LoggingTimestep *prev; | 41 | struct LoggingTimestep *prev; |
42 | |||
43 | struct GNUNET_TIME_Absolute timestamp; | ||
44 | |||
45 | /** | ||
46 | * Total number of messages this peer has sent | ||
47 | */ | ||
48 | unsigned int total_messages_sent; | ||
49 | |||
50 | /** | ||
51 | * Total number of bytes this peer has sent | ||
52 | */ | ||
53 | unsigned int total_bytes_sent; | ||
54 | |||
55 | /** | ||
56 | * Total number of messages this peer has received | ||
57 | */ | ||
58 | unsigned int total_messages_received; | ||
59 | |||
60 | /** | ||
61 | * Total number of bytes this peer has received | ||
62 | */ | ||
63 | unsigned int total_bytes_received; | ||
44 | }; | 64 | }; |
45 | 65 | ||
46 | struct LoggingPeer | 66 | struct LoggingPeer |
@@ -67,6 +87,9 @@ write_to_file () | |||
67 | char *data; | 87 | char *data; |
68 | struct LoggingTimestep *cur; | 88 | struct LoggingTimestep *cur; |
69 | int c_m; | 89 | int c_m; |
90 | unsigned int throughput_recv; | ||
91 | unsigned int throughput_send; | ||
92 | double mult; | ||
70 | 93 | ||
71 | GNUNET_asprintf (&filename, "%llu_%s.data", GNUNET_TIME_absolute_get().abs_value_us,name); | 94 | GNUNET_asprintf (&filename, "%llu_%s.data", GNUNET_TIME_absolute_get().abs_value_us,name); |
72 | 95 | ||
@@ -84,15 +107,36 @@ write_to_file () | |||
84 | { | 107 | { |
85 | for (cur = lp[c_m].head; NULL != cur; cur = cur->next) | 108 | for (cur = lp[c_m].head; NULL != cur; cur = cur->next) |
86 | { | 109 | { |
87 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 110 | mult = (1.0 * 1000 * 1000) / (LOGGING_FREQUENCY.rel_value_us); |
88 | "Master [%u]: timestamp %llu \n", lp[c_m].peer->no, cur->timestamp); | 111 | if (NULL != cur->prev) |
112 | { | ||
113 | throughput_send = cur->total_bytes_sent - cur->prev->total_bytes_sent; | ||
114 | throughput_recv = cur->total_bytes_received - cur->prev->total_bytes_received; | ||
115 | } | ||
116 | else | ||
117 | { | ||
118 | throughput_send = cur->total_bytes_sent; | ||
119 | throughput_recv = cur->total_bytes_received; | ||
120 | } | ||
121 | throughput_send *= mult; | ||
122 | throughput_recv *= mult; | ||
123 | |||
89 | 124 | ||
90 | GNUNET_asprintf (&data, "%llu;\n", cur->timestamp); | 125 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
126 | "Master [%u]: timestamp %llu %llu %u %u %u ; %u %u %u\n", lp[c_m].peer->no, | ||
127 | cur->timestamp, GNUNET_TIME_absolute_get_difference(lp[c_m].start,cur->timestamp).rel_value_us / 1000, | ||
128 | cur->total_messages_sent, cur->total_bytes_sent, throughput_send, | ||
129 | cur->total_messages_received, cur->total_bytes_received, throughput_recv); | ||
130 | |||
131 | GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u\n", | ||
132 | cur->timestamp, | ||
133 | GNUNET_TIME_absolute_get_difference(lp[c_m].start,cur->timestamp).rel_value_us / 1000, | ||
134 | cur->total_messages_sent, cur->total_bytes_sent, throughput_send, | ||
135 | cur->total_messages_received, cur->total_bytes_received, throughput_recv); | ||
91 | 136 | ||
92 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 137 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
93 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", filename); | 138 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", filename); |
94 | GNUNET_free (data); | 139 | GNUNET_free (data); |
95 | |||
96 | } | 140 | } |
97 | } | 141 | } |
98 | 142 | ||
@@ -121,15 +165,22 @@ collect_log_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
121 | { | 165 | { |
122 | lt = GNUNET_malloc (sizeof (struct LoggingTimestep)); | 166 | lt = GNUNET_malloc (sizeof (struct LoggingTimestep)); |
123 | GNUNET_CONTAINER_DLL_insert_tail(lp[c_m].head, lp[c_m].tail, lt); | 167 | GNUNET_CONTAINER_DLL_insert_tail(lp[c_m].head, lp[c_m].tail, lt); |
168 | |||
169 | /* Collect data */ | ||
124 | lt->timestamp = GNUNET_TIME_absolute_get(); | 170 | lt->timestamp = GNUNET_TIME_absolute_get(); |
171 | lt->total_bytes_sent = lp[c_m].peer->total_bytes_sent; | ||
172 | lt->total_messages_sent = lp[c_m].peer->total_messages_sent; | ||
173 | lt->total_bytes_received = lp[c_m].peer->total_bytes_received; | ||
174 | lt->total_messages_received = lp[c_m].peer->total_messages_received; | ||
125 | 175 | ||
126 | for (c_s = 0; c_s < lp[c_m].peer->num_partners; c_s++) | 176 | for (c_s = 0; c_s < lp[c_m].peer->num_partners; c_s++) |
127 | { | 177 | { |
128 | p = &peers[c_m].partners[c_s]; | 178 | p = &peers[c_m].partners[c_s]; |
129 | 179 | /* | |
130 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 180 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
131 | "Master [%u]: slave [%u]\n", | 181 | "Master [%u]: slave [%u]\n", |
132 | lp->peer->no, p->dest->no); | 182 | lp->peer->no, p->dest->no); |
183 | */ | ||
133 | } | 184 | } |
134 | } | 185 | } |
135 | 186 | ||