summaryrefslogtreecommitdiff
path: root/src/ivyperf.c
diff options
context:
space:
mode:
authorfourdan2007-01-29 10:09:59 +0000
committerfourdan2007-01-29 10:09:59 +0000
commit68e3c0ed570ba3e994f8a1c4b20594372fb0b514 (patch)
tree8d6c0d6876340742ea6f49dc9faa40aef9855563 /src/ivyperf.c
parent6fc08ea508e4fa39a9bf7f5495e84a68bd0bf88a (diff)
parentf70181ffe0b37952384ff5e0ce0185541828014f (diff)
downloadivy-c-68e3c0ed570ba3e994f8a1c4b20594372fb0b514.zip
ivy-c-68e3c0ed570ba3e994f8a1c4b20594372fb0b514.tar.gz
ivy-c-68e3c0ed570ba3e994f8a1c4b20594372fb0b514.tar.bz2
ivy-c-68e3c0ed570ba3e994f8a1c4b20594372fb0b514.tar.xz
Rename protocol_v3 as trunk to avoid confusion on protocol version to use.
Diffstat (limited to 'src/ivyperf.c')
-rwxr-xr-xsrc/ivyperf.c71
1 files changed, 36 insertions, 35 deletions
diff --git a/src/ivyperf.c b/src/ivyperf.c
index f8e9250..07453e3 100755
--- a/src/ivyperf.c
+++ b/src/ivyperf.c
@@ -39,6 +39,9 @@ extern int optind;
#include "ivyloop.h"
#define MILLISEC 1000.0
+const char *mymessages[] = { "IvyPerf", "ping", "pong" };
+static double origin = 0;
+
static double currentTime()
{
double current;
@@ -52,64 +55,62 @@ static double currentTime()
return current;
}
-void Reply (IvyClientPtr app, void *user_data, IvyArgument args)
+void Reply (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
- IvyArgument arg;
- int len;
- const void* val;
- arg = IvyArgumentGetChildrens( args );
- IvyArgumentGetValue( arg , &len, &val);
- IvySendMsg ("pong ts=%.*s tr=%f", len, (char*)val, currentTime());
+ IvySendMsg ("pong ts=%s tr=%f", *argv, currentTime()- origin);
}
-void Pong (IvyClientPtr app, void *user_data, IvyArgument args)
+void Pong (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
- double current, ts, tr, roundtrip1, roundtrip2, roundtrip3;
- IvyArgument arg;
- int len;
- const void* val;
- /* TODO bug atof non limite a la longeur de la valeur !!!*/
-
- current = currentTime();
- arg = IvyArgumentGetChildrens( args );
- IvyArgumentGetValue( arg , &len, &val);
- ts = atof( (char*)val );
- arg = IvyArgumentGetNextChild( arg );
- IvyArgumentGetValue( arg , &len, &val);
- tr = atof( (char*)val );
- roundtrip1 = tr-ts;
- roundtrip2 = current - tr;
- roundtrip3 = current - ts;
+ 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 );
}
void TimerCall(TimerId id, void *user_data, unsigned long delta)
{
- int count = IvySendMsg ("ping ts=%f", currentTime() );
+ int count = IvySendMsg ("ping ts=%f", currentTime() - origin );
if ( count == 0 ) fprintf(stderr, "." );
}
+void binCB( IvyClientPtr app, void *user_data, int id, char* regexp, IvyBindEvent event )
+{
+ char *app_name = IvyGetApplicationName( app );
+ switch ( event )
+ {
+ case IvyAddBind:
+ printf("Application:%s bind '%s' ADDED\n", app_name, regexp );
+ break;
+ case IvyRemoveBind:
+ printf("Application:%s bind '%s' REMOVED\n", app_name, regexp );
+ break;
+ case IvyFilterBind:
+ printf("Application:%s bind '%s' FILTRED\n", app_name, regexp );
+ break;
+ }
+}
int main(int argc, char *argv[])
{
-
+ long time=200;
/* Mainloop management */
+ if ( argc > 1 ) time = atol( argv[1] );
IvyInit ("IvyPerf", "IvyPerf ready", NULL,NULL,NULL,NULL);
-
-#ifdef USE_REGEXP
+ IvySetFilter( sizeof( mymessages )/ sizeof( char *),mymessages );
+ IvySetBindCallback( binCB, 0 ),
IvyBindMsg (Reply, NULL, "^ping ts=(.*)");
IvyBindMsg (Pong, NULL, "^pong ts=(.*) tr=(.*)");
-#else
- IvyBindSimpleMsg (Reply, NULL, "ping ts");
- IvyBindSimpleMsg (Pong, NULL, "pong ts tr");
-#endif
-
+ origin = currentTime();
IvyStart (0);
- TimerRepeatAfter (TIMER_LOOP, 200, TimerCall, (void*)1);
+ TimerRepeatAfter (TIMER_LOOP, time, TimerCall, (void*)1);
- IvyMainLoop (0);
+ IvyMainLoop ();
return 0;
}