diff options
author | fcolin | 2005-05-20 12:53:46 +0000 |
---|---|---|
committer | fcolin | 2005-05-20 12:53:46 +0000 |
commit | e1b08a3c4cd478ed73b78152c9ec5252bcfc395a (patch) | |
tree | 10890504b5310b368d9e4e809387dc3bc1e66d7f | |
parent | 216e4008069a5a1fe2c4270c6bd6209da27ba4bf (diff) | |
download | ivy-c-e1b08a3c4cd478ed73b78152c9ec5252bcfc395a.zip ivy-c-e1b08a3c4cd478ed73b78152c9ec5252bcfc395a.tar.gz ivy-c-e1b08a3c4cd478ed73b78152c9ec5252bcfc395a.tar.bz2 ivy-c-e1b08a3c4cd478ed73b78152c9ec5252bcfc395a.tar.xz |
un test de performance d'ivy a lancer en deux exemplaires
donne le temps de roundtrip d'un ping pong
-rwxr-xr-x | src/ivyperf.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/ivyperf.c b/src/ivyperf.c new file mode 100755 index 0000000..11e9522 --- /dev/null +++ b/src/ivyperf.c @@ -0,0 +1,95 @@ +/* + * Ivy perf mesure le temp de round trip + * + * Copyright (C) 1997-2004 + * Centre d'Études de la Navigation Aérienne + * + * Main and only file + * + * Authors: François-Régis Colin <fcolin@cena.fr> + * Yannick Jestin <jestin@cena.fr> + * + * Please refer to file version.h for the + * copyright notice regarding this software + */ + +#include "version.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#ifdef WIN32 +#include <windows.h> +#ifdef __MINGW32__ +#include <regex.h> +#include <getopt.h> +#endif +#else +#include <sys/time.h> +#include <unistd.h> +#ifdef __INTERIX +extern char *optarg; +extern int optind; +#endif +#endif + + +#include "ivysocket.h" +#include "ivy.h" +#include "timer.h" +#include "ivyloop.h" +#define MILLISEC 1000.0 + +static double currentTime() +{ + double current; +#ifdef WIN32 + current = GetTickCount(); +#else + struct timeval stamp; + gettimeofday( &stamp, NULL ); + current = (double)stamp.tv_sec * MILLISEC + (double)(stamp.tv_usec/MILLISEC); +#endif + return current; +} + +void Reply (IvyClientPtr app, void *user_data, int argc, char *argv[]) +{ + IvySendMsg ("pong ts=%s tr=%f", *argv, currentTime()); +} +void Pong (IvyClientPtr app, void *user_data, int argc, char *argv[]) +{ + double current = currentTime(); + 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() ); + if ( count == 0 ) fprintf(stderr, "." ); +} + + +int main(int argc, char *argv[]) +{ + + + /* Mainloop management */ + + IvyInit ("IvyPerf", "IvyPerf ready", NULL,NULL,NULL,NULL); + + IvyBindMsg (Reply, NULL, "^ping ts=(.*)"); + IvyBindMsg (Pong, NULL, "^pong ts=(.*) tr=(.*)"); + + IvyStart (0); + + TimerRepeatAfter (TIMER_LOOP, 200, TimerCall, (void*)1); + + + IvyMainLoop (0); + return 0; +} |