/* Test program (performance) */ #include #include #include #include #include #include "bolibfs.h" #include "bolixo.h" static long long getnow() { struct timeval tv; gettimeofday (&tv,NULL); return tv.tv_sec *(long long)1000000 + tv.tv_usec; } static void print_time (long long start, const char *msg) { long long diff = getnow()-start; fprintf (stderr,"TIME: %s %6ld.%06ld\n",msg,(long)(diff/1000000) ,(long)(diff % 1000000)); } int main (int argc, char *argv[]) { glocal int nb = 100; glocal bool testping = false; glocal bool testxmlping = false; glocal bool testtcpcon = false; static const char *tb[]={"bolixo","tlmpsql",NULL}; (argc,argv,tb); setarg ('n',"nbiter","Loop count",glocal.nb,false); setarg ('p',"ping","Test the ping command",glocal.testping,false); setarg ('x',"xmlping","Test the xmlping command",glocal.testxmlping,false); setarg ('t',"tcpconnect","Use tcpconnect",glocal.testtcpcon,false); SSTRING errmsg; int fd = bomisc_connect("localhost","9876","jack","pass","mail",errmsg); if (fd == -1){ tlmp_error ("Can't connect\n"); }else{ glocal long long start = getnow(); if (glocal.testping){ glocal int nbline = 0; for (int i=0; i(fd,10); glocal.nbline++; end = true; }else{ char buf[1000]; int len = read (fd,buf,sizeof(buf)-1); glocal.nbline++; } } print_time (glocal.start,"ping"); fprintf (stderr,"Received %d lines\n",glocal.nbline); }else if (glocal.testxmlping){ glocal int nbline = 0; for (int i=0; i(fd,10); glocal.nbline++; end = strcmp(line,"")==0; long long diff = getnow() - glocal.start; fprintf (stderr,"%6ld.%06ld Rec :%s: %d\n" ,(long)(diff/1000000) ,(long)(diff%1000000) ,line,end); }else{ (fd); } } print_time (glocal.start,"xmlping"); if (glocal.testtcpcon){ fprintf (stderr,"Received %d lines\n",glocal.nbline); } }else{ tlmp_error ("Option -x or -p needed\n"); usage(); } } return 0; return 0; }