Commit 93ccec2fef14e069c30fb5c97bf5b23178e612bf

Authored by Georg Hopp
1 parent b7d83002

show some information about the bytes per second throughput. Currently I manage …

…around 1.1 GBytes on a loopback device which sounds not to bad, but is only about 1/4 of the throughput iperf shows me... but this might be related to nc... I will see this when I have written my own client.
@@ -11,10 +11,28 @@ static @@ -11,10 +11,28 @@ static
11 TR_EventDone 11 TR_EventDone
12 testHandlerHeartbeat(TR_EventHandler this, TR_Event event) 12 testHandlerHeartbeat(TR_EventHandler this, TR_Event event)
13 { 13 {
14 - printf("%zd beat(s) since last beat / handled: %llu/s\n", 14 + double size = (double)((TestHandler)this)->size;
  15 + double size_msg = ((TestHandler)this)->size
  16 + ? size / ((TestHandler)this)->handled
  17 + : 0.0;
  18 + int div_count = 0;
  19 +
  20 + while (size > 1024. && div_count != 'G') {
  21 + size /= 1024.;
  22 + switch (div_count) {
  23 + case 0: div_count = 'K'; break;
  24 + case 'K': div_count = 'M'; break;
  25 + case 'M': div_count = 'G'; break;
  26 + }
  27 + }
  28 +
  29 + printf("%zd beat(s) since last beat / "
  30 + "handled: %llu msg/s %4.2lf %cBytes/s %4.0lf Bytes/msg\n",
15 ((TR_EventDispatcher)event->subject)->n_beats, 31 ((TR_EventDispatcher)event->subject)->n_beats,
16 - ((TestHandler)this)->handled); 32 + ((TestHandler)this)->handled,
  33 + size, div_count, size_msg);
17 ((TestHandler)this)->handled = 0; 34 ((TestHandler)this)->handled = 0;
  35 + ((TestHandler)this)->size = 0;
18 36
19 return TR_EVENT_DONE; 37 return TR_EVENT_DONE;
20 } 38 }
@@ -23,9 +41,11 @@ static @@ -23,9 +41,11 @@ static
23 TR_EventDone 41 TR_EventDone
24 testHandlerNewMessage(TR_EventHandler this, TR_Event event) 42 testHandlerNewMessage(TR_EventHandler this, TR_Event event)
25 { 43 {
26 - TR_Event _event; 44 + TR_Event _event;
  45 + TR_ProtoMessageRaw message = event->data;
27 46
28 ((TestHandler)this)->handled++; 47 ((TestHandler)this)->handled++;
  48 + ((TestHandler)this)->size += ((TR_SizedData)message->data)->size;
29 49
30 _event = TR_eventSubjectEmit( 50 _event = TR_eventSubjectEmit(
31 event->subject, 51 event->subject,
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 TR_CLASS(TestHandler) { 9 TR_CLASS(TestHandler) {
10 TR_EXTENDS(TR_EventHandler); 10 TR_EXTENDS(TR_EventHandler);
11 unsigned long long handled; 11 unsigned long long handled;
  12 + unsigned long long size;
12 }; 13 };
13 TR_INSTANCE_INIT(TestHandler); 14 TR_INSTANCE_INIT(TestHandler);
14 TR_CLASSVARS_DECL(TestHandler) { 15 TR_CLASSVARS_DECL(TestHandler) {
1 #!/bin/sh 1 #!/bin/sh
2 2
3 BS=$((128*1024)) 3 BS=$((128*1024))
4 -COUNT=10000  
5 -CONCURENT=200 4 +COUNT=1000000
  5 +CONCURENT=2
6 IP="192.168.2.13" 6 IP="192.168.2.13"
7 pids="" 7 pids=""
8 i=0 8 i=0
Please register or login to post a comment