summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorfcolin2009-07-06 08:38:06 +0000
committerfcolin2009-07-06 08:38:06 +0000
commit41ab25636882f12eed1c31a818a70aed12a46bbf (patch)
tree88ba46ce68675d98c784d77efee20d5b9b0559d1 /tools
parent854c4213d33279e1b30a63f48760a9ffae16d9ed (diff)
downloadivy-c-41ab25636882f12eed1c31a818a70aed12a46bbf.zip
ivy-c-41ab25636882f12eed1c31a818a70aed12a46bbf.tar.gz
ivy-c-41ab25636882f12eed1c31a818a70aed12a46bbf.tar.bz2
ivy-c-41ab25636882f12eed1c31a818a70aed12a46bbf.tar.xz
modif mesure du temps min moy avg
Diffstat (limited to 'tools')
-rw-r--r--tools/ivyperf.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/tools/ivyperf.c b/tools/ivyperf.c
index 8babd35..402c08d 100644
--- a/tools/ivyperf.c
+++ b/tools/ivyperf.c
@@ -41,6 +41,14 @@ extern int optind;
const char *mymessages[] = { "IvyPerf", "ping", "pong" };
static double origin = 0;
+int nbMsgReceive=0;
+int nbMsgEmit=0;
+int nbMsg = 10;
+
+
+double minRoundTrip=1e12;
+double maxRoundTrip=0;
+double averageRoundTrip=0;
static double currentTime()
{
@@ -54,6 +62,8 @@ static double currentTime()
#endif
return current;
}
+TimerId send_timer;
+
void Reply (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
@@ -61,19 +71,35 @@ void Reply (IvyClientPtr app, void *user_data, int argc, char *argv[])
}
void Pong (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
+ nbMsgReceive++;
+
double current = currentTime() - origin ;
double ts = atof( *argv++ );
double tr = atof( *argv++ );
double roundtrip1 = tr-ts;
double roundtrip2 = current - tr;
double roundtrip3 = current - ts;
- fprintf(stderr,"roundtrip %f %f %f \n", roundtrip1, roundtrip2, roundtrip3 );
+ if ( roundtrip3 > maxRoundTrip ) maxRoundTrip = roundtrip3;
+ if ( roundtrip3 < minRoundTrip ) minRoundTrip = roundtrip3;
+ averageRoundTrip = (averageRoundTrip * ( nbMsgReceive - 1 ) + roundtrip3) /nbMsgReceive;
+
+ if ( nbMsg == nbMsgReceive )
+ {
+ printf("roundtrip[%d] min %f av %f max %f ms\n", nbMsgReceive, minRoundTrip, averageRoundTrip, maxRoundTrip );
+ //IvyStop();
+ }
+
}
void TimerCall(TimerId id, void *user_data, unsigned long delta)
{
int count = IvySendMsg ("ping ts=%f", currentTime() - origin );
- if ( count == 0 ) fprintf(stderr, "." );
+ if ( count ) nbMsgEmit++;
+ if ( nbMsg == nbMsgEmit )
+ {
+ TimerRemove(send_timer);
+ //IvyStop();
+ }
}
void binCB( IvyClientPtr app, void *user_data, int id, const char* regexp, IvyBindEvent event )
@@ -99,19 +125,22 @@ void binCB( IvyClientPtr app, void *user_data, int id, const char* regexp, IvyB
int main(int argc, char *argv[])
{
long time=200;
-
+
/* Mainloop management */
if ( argc > 1 ) time = atol( argv[1] );
+ if ( argc > 2 ) nbMsg = atol( argv[2] );
IvyInit ("IvyPerf", "IvyPerf ready", NULL,NULL,NULL,NULL);
IvySetFilter( sizeof( mymessages )/ sizeof( char *),mymessages );
IvySetBindCallback( binCB, 0 ),
IvyBindMsg (Reply, NULL, "^ping ts=(.*)");
IvyBindMsg (Pong, NULL, "^pong ts=(.*) tr=(.*)");
+
origin = currentTime();
IvyStart (0);
- TimerRepeatAfter (TIMER_LOOP, time, TimerCall, (void*)1);
+ if ( nbMsg )
+ send_timer = TimerRepeatAfter (TIMER_LOOP, time, TimerCall, (void*)nbMsg);
IvyMainLoop ();