aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-09-01 09:08:41 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-09-01 09:08:41 +0000
commit057dd15cd4f12ebd40bff92e66116a78eb1f9ec0 (patch)
tree42f9e0f15b4f8248cc4cdbbb2521c0eb43620081 /src/transport
parent48529094fd68b612d38616bbf2e16fd022ba8a72 (diff)
downloadgnunet-057dd15cd4f12ebd40bff92e66116a78eb1f9ec0.tar.gz
gnunet-057dd15cd4f12ebd40bff92e66116a78eb1f9ec0.zip
improved profiler
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-transport-profiler.c68
1 files changed, 63 insertions, 5 deletions
diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c
index 8c41ea2b5..fc3c32a40 100644
--- a/src/transport/gnunet-transport-profiler.c
+++ b/src/transport/gnunet-transport-profiler.c
@@ -41,6 +41,9 @@ struct Iteration
41 41
42 struct GNUNET_TIME_Relative dur; 42 struct GNUNET_TIME_Relative dur;
43 43
44 /* Transmission rate for this iteration in KB/s */
45 float rate;
46
44 unsigned int msgs_sent; 47 unsigned int msgs_sent;
45}; 48};
46 49
@@ -160,6 +163,13 @@ shutdown_task (void *cls,
160 struct Iteration *icur; 163 struct Iteration *icur;
161 struct Iteration *inext; 164 struct Iteration *inext;
162 165
166 unsigned int iterations;
167
168 unsigned long long avg_duration;
169 float avg_rate;
170 float stddev_rate;
171 float stddev_duration;
172
163 if (NULL != tc_handle) 173 if (NULL != tc_handle)
164 { 174 {
165 GNUNET_TRANSPORT_try_connect_cancel (tc_handle); 175 GNUNET_TRANSPORT_try_connect_cancel (tc_handle);
@@ -183,27 +193,75 @@ shutdown_task (void *cls,
183 handle = NULL; 193 handle = NULL;
184 } 194 }
185 195
196 if (verbosity > 0)
197 FPRINTF (stdout, "\n");
198
199 /* Output format:
200 * All time values in ms
201 * Rate in KB/s
202 * #messages;#messagesize;#avg_dur;#avg_rate;#duration_i0;#duration_i0;... */
203
186 if (benchmark_send) 204 if (benchmark_send)
187 { 205 {
206 /* First iteration to calculcate avg and stddev */
207 iterations = 0;
208 avg_duration = 0;
209 avg_rate = 0.0;
210
188 inext = ihead; 211 inext = ihead;
189 while (NULL != (icur = inext)) 212 while (NULL != (icur = inext))
190 { 213 {
191 inext = icur->next; 214 inext = icur->next;
215 icur->rate = ((benchmark_count * benchmark_size) / 1024) /
216 ((float) icur->dur.rel_value_us / (1000 * 1000));
192 if (verbosity > 0) 217 if (verbosity > 0)
193 FPRINTF (stdout, _("%llu B in %llu ms == %.2f KB/s!\n"), 218 FPRINTF (stdout, _("%llu B in %llu ms == %.2f KB/s!\n"),
194 ((long long unsigned int) benchmark_count * benchmark_size), 219 ((long long unsigned int) benchmark_count * benchmark_size),
195 ((long long unsigned int) itail->dur.rel_value_us / 1000), 220 ((long long unsigned int) icur->dur.rel_value_us / 1000),
196 (float) ((benchmark_count * benchmark_size) / 1024)/ ((float) itail->dur.rel_value_us / (1000 * 1000))); 221 (float) icur->rate);
222
223 avg_duration += icur->dur.rel_value_us / (1000);
224 avg_rate += icur->rate;
225 iterations ++;
197 } 226 }
198 FPRINTF (stdout, _("%u;%u"),benchmark_count, benchmark_size); 227
228 /* Calculate average rate */
229 avg_rate /= iterations;
230 /* Calculate average duration */
231 avg_duration /= iterations;
232
233 stddev_rate = 0;
234 stddev_duration = 0;
235 inext = ihead;
236 while (NULL != (icur = inext))
237 {
238 inext = icur->next;
239 stddev_rate += ((icur->rate-avg_rate) *
240 (icur->rate-avg_rate));
241 stddev_duration += (((icur->dur.rel_value_us / 1000) - avg_duration) *
242 ((icur->dur.rel_value_us / 1000) - avg_duration));
243
244 }
245 /* Calculate standard deviation rate */
246 stddev_rate = stddev_rate / iterations;
247 stddev_rate = sqrtf(stddev_rate);
248
249 /* Calculate standard deviation duration */
250 stddev_duration = stddev_duration / iterations;
251 stddev_duration = sqrtf(stddev_duration);
252
253 /* Output */
254 FPRINTF (stdout, _("%u;%u;%llu;%llu;%.2f;%.2f"),benchmark_count, benchmark_size,
255 avg_duration, (unsigned long long) stddev_duration, avg_rate, stddev_rate);
256
199 inext = ihead; 257 inext = ihead;
200 while (NULL != (icur = inext)) 258 while (NULL != (icur = inext))
201 { 259 {
202 inext = icur->next; 260 inext = icur->next;
203 GNUNET_CONTAINER_DLL_remove (ihead, itail, icur); 261 GNUNET_CONTAINER_DLL_remove (ihead, itail, icur);
204 262
205 FPRINTF (stdout, _(";%llu"), 263 FPRINTF (stdout, _(";%llu;%.2f"),
206 (long long unsigned int) icur->dur.rel_value_us); 264 (long long unsigned int) (icur->dur.rel_value_us / 1000), icur->rate);
207 265
208 GNUNET_free (icur); 266 GNUNET_free (icur);
209 } 267 }