aboutsummaryrefslogtreecommitdiff
path: root/src/ats-tests/perf_ats_logging.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-09-19 07:45:09 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-09-19 07:45:09 +0000
commitcfdc5b2d2c092cdb5efa5a64e9cc1df6ef26de58 (patch)
tree22bfffba75df4e295aa9861d9a28ac6aea2d2f3e /src/ats-tests/perf_ats_logging.c
parent59402687b837c12990b00d94799323d327e608bd (diff)
downloadgnunet-cfdc5b2d2c092cdb5efa5a64e9cc1df6ef26de58.tar.gz
gnunet-cfdc5b2d2c092cdb5efa5a64e9cc1df6ef26de58.zip
slave logging
Diffstat (limited to 'src/ats-tests/perf_ats_logging.c')
-rw-r--r--src/ats-tests/perf_ats_logging.c126
1 files changed, 105 insertions, 21 deletions
diff --git a/src/ats-tests/perf_ats_logging.c b/src/ats-tests/perf_ats_logging.c
index 51c09c266..2979dd647 100644
--- a/src/ats-tests/perf_ats_logging.c
+++ b/src/ats-tests/perf_ats_logging.c
@@ -27,19 +27,70 @@
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, 100) 30#define LOGGING_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 500)
31 31
32
33/**
34 * Logging task
35 */
32static GNUNET_SCHEDULER_TaskIdentifier log_task; 36static GNUNET_SCHEDULER_TaskIdentifier log_task;
33 37
34static struct BenchmarkPeer *peers; 38/**
39 * Reference to perf_ats' masters
40 */
35static int num_peers; 41static int num_peers;
36static char *name; 42static char *name;
37 43
38struct LoggingTimestep 44/**
45 * A single logging time step for a partner
46 */
47struct PartnerLoggingTimestep
48{
49 /**
50 * Peer
51 */
52 struct BenchmarkPeer *slave;
53
54 /**
55 * Total number of messages this peer has sent
56 */
57 unsigned int total_messages_sent;
58
59 /**
60 * Total number of bytes this peer has sent
61 */
62 unsigned int total_bytes_sent;
63
64 /**
65 * Total number of messages this peer has received
66 */
67 unsigned int total_messages_received;
68
69 /**
70 * Total number of bytes this peer has received
71 */
72 unsigned int total_bytes_received;
73};
74
75
76/**
77 * A single logging time step for a peer
78 */
79struct PeerLoggingTimestep
39{ 80{
40 struct LoggingTimestep *next; 81 /**
41 struct LoggingTimestep *prev; 82 * Next in DLL
83 */
84 struct PeerLoggingTimestep *next;
42 85
86 /**
87 * Prev in DLL
88 */
89 struct PeerLoggingTimestep *prev;
90
91 /**
92 * Logging timestamp
93 */
43 struct GNUNET_TIME_Absolute timestamp; 94 struct GNUNET_TIME_Absolute timestamp;
44 95
45 /** 96 /**
@@ -61,16 +112,37 @@ struct LoggingTimestep
61 * Total number of bytes this peer has received 112 * Total number of bytes this peer has received
62 */ 113 */
63 unsigned int total_bytes_received; 114 unsigned int total_bytes_received;
115
116 /**
117 * Logs for slaves
118 */
119 struct PartnerLoggingTimestep *slaves_log;
64}; 120};
65 121
122/**
123 * Entry for a benchmark peer
124 */
66struct LoggingPeer 125struct LoggingPeer
67{ 126{
127 /**
128 * Peer
129 */
68 struct BenchmarkPeer *peer; 130 struct BenchmarkPeer *peer;
69 131
132 /**
133 * Start time
134 */
70 struct GNUNET_TIME_Absolute start; 135 struct GNUNET_TIME_Absolute start;
71 136
72 struct LoggingTimestep *head; 137 /**
73 struct LoggingTimestep *tail; 138 * DLL for logging entries: head
139 */
140 struct PeerLoggingTimestep *head;
141
142 /**
143 * DLL for logging entries: tail
144 */
145 struct PeerLoggingTimestep *tail;
74}; 146};
75 147
76/** 148/**
@@ -85,8 +157,9 @@ write_to_file ()
85 struct GNUNET_DISK_FileHandle *f; 157 struct GNUNET_DISK_FileHandle *f;
86 char * filename; 158 char * filename;
87 char *data; 159 char *data;
88 struct LoggingTimestep *cur; 160 struct PeerLoggingTimestep *cur;
89 int c_m; 161 int c_m;
162 //int c_s;
90 unsigned int throughput_recv; 163 unsigned int throughput_recv;
91 unsigned int throughput_send; 164 unsigned int throughput_send;
92 double mult; 165 double mult;
@@ -128,6 +201,8 @@ write_to_file ()
128 cur->total_messages_sent, cur->total_bytes_sent, throughput_send, 201 cur->total_messages_sent, cur->total_bytes_sent, throughput_send,
129 cur->total_messages_received, cur->total_bytes_received, throughput_recv); 202 cur->total_messages_received, cur->total_bytes_received, throughput_recv);
130 203
204// for ()
205
131 GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u\n", 206 GNUNET_asprintf (&data, "%llu;%llu;%u;%u;%u;%u;%u;%u\n",
132 cur->timestamp, 207 cur->timestamp,
133 GNUNET_TIME_absolute_get_difference(lp[c_m].start,cur->timestamp).rel_value_us / 1000, 208 GNUNET_TIME_absolute_get_difference(lp[c_m].start,cur->timestamp).rel_value_us / 1000,
@@ -156,31 +231,40 @@ collect_log_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
156{ 231{
157 int c_m; 232 int c_m;
158 int c_s; 233 int c_s;
159 struct LoggingTimestep *lt; 234 struct PeerLoggingTimestep *mlt;
235 struct PartnerLoggingTimestep *slt;
160 struct BenchmarkPartner *p; 236 struct BenchmarkPartner *p;
161 237
162 log_task = GNUNET_SCHEDULER_NO_TASK; 238 log_task = GNUNET_SCHEDULER_NO_TASK;
163 239
164 for (c_m = 0; c_m < num_peers; c_m++) 240 for (c_m = 0; c_m < num_peers; c_m++)
165 { 241 {
166 lt = GNUNET_malloc (sizeof (struct LoggingTimestep)); 242 mlt = GNUNET_malloc (sizeof (struct PeerLoggingTimestep));
167 GNUNET_CONTAINER_DLL_insert_tail(lp[c_m].head, lp[c_m].tail, lt); 243 GNUNET_CONTAINER_DLL_insert_tail(lp[c_m].head, lp[c_m].tail, mlt);
168 244
169 /* Collect data */ 245 /* Collect data */
170 lt->timestamp = GNUNET_TIME_absolute_get(); 246 mlt->timestamp = GNUNET_TIME_absolute_get();
171 lt->total_bytes_sent = lp[c_m].peer->total_bytes_sent; 247 mlt->total_bytes_sent = lp[c_m].peer->total_bytes_sent;
172 lt->total_messages_sent = lp[c_m].peer->total_messages_sent; 248 mlt->total_messages_sent = lp[c_m].peer->total_messages_sent;
173 lt->total_bytes_received = lp[c_m].peer->total_bytes_received; 249 mlt->total_bytes_received = lp[c_m].peer->total_bytes_received;
174 lt->total_messages_received = lp[c_m].peer->total_messages_received; 250 mlt->total_messages_received = lp[c_m].peer->total_messages_received;
251
252 mlt->slaves_log = GNUNET_malloc (lp[c_m].peer->num_partners *
253 sizeof (struct PartnerLoggingTimestep));
175 254
176 for (c_s = 0; c_s < lp[c_m].peer->num_partners; c_s++) 255 for (c_s = 0; c_s < lp[c_m].peer->num_partners; c_s++)
177 { 256 {
178 p = &peers[c_m].partners[c_s]; 257 p = &lp[c_m].peer->partners[c_s];
179/* 258 slt = &mlt->slaves_log[c_s];
259 slt->slave = p->dest;
260 slt->total_bytes_sent = p->dest->total_bytes_sent;
261 slt->total_messages_sent = p->dest->total_messages_sent;
262 slt->total_bytes_received = p->dest->total_bytes_received;
263 slt->total_messages_received = p->dest->total_messages_received;
264
180 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 265 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
181 "Master [%u]: slave [%u]\n", 266 "Master [%u]: slave [%u]\n",
182 lp->peer->no, p->dest->no); 267 lp->peer->no, p->dest->no);
183*/
184 } 268 }
185 } 269 }
186 270
@@ -197,7 +281,7 @@ perf_logging_stop ()
197{ 281{
198 int c_m; 282 int c_m;
199 struct GNUNET_SCHEDULER_TaskContext tc; 283 struct GNUNET_SCHEDULER_TaskContext tc;
200 struct LoggingTimestep *cur; 284 struct PeerLoggingTimestep *cur;
201 285
202 if (GNUNET_SCHEDULER_NO_TASK != log_task) 286 if (GNUNET_SCHEDULER_NO_TASK != log_task)
203 GNUNET_SCHEDULER_cancel (log_task); 287 GNUNET_SCHEDULER_cancel (log_task);
@@ -215,6 +299,7 @@ perf_logging_stop ()
215 while (NULL != (cur = lp[c_m].head)) 299 while (NULL != (cur = lp[c_m].head))
216 { 300 {
217 GNUNET_CONTAINER_DLL_remove (lp[c_m].head, lp[c_m].tail, cur); 301 GNUNET_CONTAINER_DLL_remove (lp[c_m].head, lp[c_m].tail, cur);
302 GNUNET_free (cur->slaves_log);
218 GNUNET_free (cur); 303 GNUNET_free (cur);
219 } 304 }
220 } 305 }
@@ -229,7 +314,6 @@ perf_logging_start (char * testname, struct BenchmarkPeer *masters, int num_mast
229 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 314 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
230 _("Start logging `%s'\n"), testname); 315 _("Start logging `%s'\n"), testname);
231 316
232 peers = masters;
233 num_peers = num_masters; 317 num_peers = num_masters;
234 name = testname; 318 name = testname;
235 319