diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-09-19 08:40:25 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-09-19 08:40:25 +0000 |
commit | 50314c5f4bacdc8a296f176a124fa505ed834cf0 (patch) | |
tree | b2a48823432bb59f843c2832394178f1b4de0f57 /src/ats-tests/perf_ats_logging.c | |
parent | 44da7c75264ac48c113ffecb6593169793f89956 (diff) | |
download | gnunet-50314c5f4bacdc8a296f176a124fa505ed834cf0.tar.gz gnunet-50314c5f4bacdc8a296f176a124fa505ed834cf0.zip |
logging done
Diffstat (limited to 'src/ats-tests/perf_ats_logging.c')
-rw-r--r-- | src/ats-tests/perf_ats_logging.c | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/src/ats-tests/perf_ats_logging.c b/src/ats-tests/perf_ats_logging.c index e52ac4b0d..def466bfd 100644 --- a/src/ats-tests/perf_ats_logging.c +++ b/src/ats-tests/perf_ats_logging.c | |||
@@ -39,6 +39,7 @@ static GNUNET_SCHEDULER_TaskIdentifier log_task; | |||
39 | * Reference to perf_ats' masters | 39 | * Reference to perf_ats' masters |
40 | */ | 40 | */ |
41 | static int num_peers; | 41 | static int num_peers; |
42 | static int running; | ||
42 | static char *name; | 43 | static char *name; |
43 | 44 | ||
44 | /** | 45 | /** |
@@ -157,6 +158,8 @@ write_to_file () | |||
157 | struct GNUNET_DISK_FileHandle *f; | 158 | struct GNUNET_DISK_FileHandle *f; |
158 | char * filename; | 159 | char * filename; |
159 | char *data; | 160 | char *data; |
161 | char *slave_string; | ||
162 | char *slave_string_tmp; | ||
160 | struct PeerLoggingTimestep *cur_lt; | 163 | struct PeerLoggingTimestep *cur_lt; |
161 | struct PartnerLoggingTimestep *plt; | 164 | struct PartnerLoggingTimestep *plt; |
162 | int c_m; | 165 | int c_m; |
@@ -167,20 +170,22 @@ write_to_file () | |||
167 | unsigned int throughput_send_slave; | 170 | unsigned int throughput_send_slave; |
168 | double mult; | 171 | double mult; |
169 | 172 | ||
170 | GNUNET_asprintf (&filename, "%llu_%s.data", GNUNET_TIME_absolute_get().abs_value_us,name); | ||
171 | |||
172 | f = GNUNET_DISK_file_open (filename, | ||
173 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
174 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
175 | if (NULL == f) | ||
176 | { | ||
177 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename); | ||
178 | GNUNET_free (filename); | ||
179 | return; | ||
180 | } | ||
181 | |||
182 | for (c_m = 0; c_m < num_peers; c_m++) | 173 | for (c_m = 0; c_m < num_peers; c_m++) |
183 | { | 174 | { |
175 | GNUNET_asprintf (&filename, "%llu_master_[%u]_%s _%s.data", GNUNET_TIME_absolute_get().abs_value_us, | ||
176 | lp[c_m].peer->no, GNUNET_i2s(&lp[c_m].peer->id), name); | ||
177 | |||
178 | f = GNUNET_DISK_file_open (filename, | ||
179 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_CREATE, | ||
180 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
181 | if (NULL == f) | ||
182 | { | ||
183 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot open log file `%s'\n", filename); | ||
184 | GNUNET_free (filename); | ||
185 | return; | ||
186 | } | ||
187 | |||
188 | |||
184 | for (cur_lt = lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next) | 189 | for (cur_lt = lp[c_m].head; NULL != cur_lt; cur_lt = cur_lt->next) |
185 | { | 190 | { |
186 | mult = (1.0 * 1000 * 1000) / (LOGGING_FREQUENCY.rel_value_us); | 191 | mult = (1.0 * 1000 * 1000) / (LOGGING_FREQUENCY.rel_value_us); |
@@ -204,6 +209,7 @@ write_to_file () | |||
204 | cur_lt->total_messages_sent, cur_lt->total_bytes_sent, throughput_send, | 209 | cur_lt->total_messages_sent, cur_lt->total_bytes_sent, throughput_send, |
205 | cur_lt->total_messages_received, cur_lt->total_bytes_received, throughput_recv); | 210 | cur_lt->total_messages_received, cur_lt->total_bytes_received, throughput_recv); |
206 | 211 | ||
212 | slave_string = GNUNET_strdup (";"); | ||
207 | for (c_s = 0; c_s < lp[c_m].peer->num_partners; c_s++) | 213 | for (c_s = 0; c_s < lp[c_m].peer->num_partners; c_s++) |
208 | { | 214 | { |
209 | /* Log partners */ | 215 | /* Log partners */ |
@@ -225,29 +231,37 @@ write_to_file () | |||
225 | "\t Slave [%u]: %u %u %u ; %u %u %u \n", plt->slave->no, | 231 | "\t Slave [%u]: %u %u %u ; %u %u %u \n", plt->slave->no, |
226 | plt->total_messages_sent, plt->total_bytes_sent, throughput_send_slave, | 232 | plt->total_messages_sent, plt->total_bytes_sent, throughput_send_slave, |
227 | plt->total_messages_received, plt->total_bytes_received, throughput_recv_slave); | 233 | plt->total_messages_received, plt->total_bytes_received, throughput_recv_slave); |
234 | |||
235 | |||
236 | GNUNET_asprintf(&slave_string_tmp, "%s%u;%u;%u;%u;%u;%u;",slave_string, | ||
237 | plt->total_messages_sent, plt->total_bytes_sent, throughput_send_slave, | ||
238 | plt->total_messages_received, plt->total_bytes_received, throughput_recv_slave); | ||
239 | GNUNET_free (slave_string); | ||
240 | slave_string = slave_string_tmp; | ||
228 | } | 241 | } |
229 | 242 | ||
230 | GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u\n", | 243 | GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u%s\n", |
231 | cur_lt->timestamp, | 244 | cur_lt->timestamp, |
232 | GNUNET_TIME_absolute_get_difference(lp[c_m].start,cur_lt->timestamp).rel_value_us / 1000, | 245 | GNUNET_TIME_absolute_get_difference(lp[c_m].start,cur_lt->timestamp).rel_value_us / 1000, |
233 | cur_lt->total_messages_sent, cur_lt->total_bytes_sent, throughput_send, | 246 | cur_lt->total_messages_sent, cur_lt->total_bytes_sent, throughput_send, |
234 | cur_lt->total_messages_received, cur_lt->total_bytes_received, throughput_recv); | 247 | cur_lt->total_messages_received, cur_lt->total_bytes_received, throughput_recv, |
248 | slave_string); | ||
249 | GNUNET_free (slave_string); | ||
235 | 250 | ||
236 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) | 251 | if (GNUNET_SYSERR == GNUNET_DISK_file_write(f, data, strlen(data))) |
237 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", filename); | 252 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot write data to log file `%s'\n", filename); |
238 | GNUNET_free (data); | 253 | GNUNET_free (data); |
239 | } | 254 | } |
240 | } | 255 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) |
256 | { | ||
257 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", filename); | ||
258 | GNUNET_free (filename); | ||
259 | return; | ||
260 | } | ||
241 | 261 | ||
242 | if (GNUNET_SYSERR == GNUNET_DISK_file_close(f)) | 262 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data file successfully written to log file `%s'\n", filename); |
243 | { | ||
244 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot close log file `%s'\n", filename); | ||
245 | GNUNET_free (filename); | 263 | GNUNET_free (filename); |
246 | return; | ||
247 | } | 264 | } |
248 | |||
249 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Data file successfully written to log file `%s'\n", filename); | ||
250 | GNUNET_free (filename); | ||
251 | } | 265 | } |
252 | 266 | ||
253 | static void | 267 | static void |
@@ -286,9 +300,9 @@ collect_log_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
286 | slt->total_bytes_received = p->dest->total_bytes_received; | 300 | slt->total_bytes_received = p->dest->total_bytes_received; |
287 | slt->total_messages_received = p->dest->total_messages_received; | 301 | slt->total_messages_received = p->dest->total_messages_received; |
288 | 302 | ||
289 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 303 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
290 | "Master [%u]: slave [%u]\n", | 304 | "Master [%u]: slave [%u]\n", |
291 | lp->peer->no, p->dest->no); | 305 | lp[c_m].peer->no, p->dest->no); |
292 | } | 306 | } |
293 | } | 307 | } |
294 | 308 | ||
@@ -307,6 +321,9 @@ perf_logging_stop () | |||
307 | struct GNUNET_SCHEDULER_TaskContext tc; | 321 | struct GNUNET_SCHEDULER_TaskContext tc; |
308 | struct PeerLoggingTimestep *cur; | 322 | struct PeerLoggingTimestep *cur; |
309 | 323 | ||
324 | if (GNUNET_YES!= running) | ||
325 | return; | ||
326 | |||
310 | if (GNUNET_SCHEDULER_NO_TASK != log_task) | 327 | if (GNUNET_SCHEDULER_NO_TASK != log_task) |
311 | GNUNET_SCHEDULER_cancel (log_task); | 328 | GNUNET_SCHEDULER_cancel (log_task); |
312 | log_task = GNUNET_SCHEDULER_NO_TASK; | 329 | log_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -351,6 +368,7 @@ perf_logging_start (char * testname, struct BenchmarkPeer *masters, int num_mast | |||
351 | 368 | ||
352 | /* Schedule logging task */ | 369 | /* Schedule logging task */ |
353 | log_task = GNUNET_SCHEDULER_add_now (&collect_log_task, NULL); | 370 | log_task = GNUNET_SCHEDULER_add_now (&collect_log_task, NULL); |
371 | running = GNUNET_YES; | ||
354 | } | 372 | } |
355 | /* end of file perf_ats_logging.c */ | 373 | /* end of file perf_ats_logging.c */ |
356 | 374 | ||