Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

iotest.c File Reference

#include "mrilib.h"

Go to the source code of this file.


Defines

#define WDEL   1
#define RDEL   1

Functions

int main (int argc, char *argv[])

Define Documentation

#define RDEL   1
 

Definition at line 4 of file iotest.c.

Referenced by main().

#define WDEL   1
 

Definition at line 3 of file iotest.c.

Referenced by main().


Function Documentation

int main int    argc,
char *    argv[]
 

\** File : SUMA.c

Author:
: Ziad Saad Date : Thu Dec 27 16:21:01 EST 2001
Purpose :

Input paramters :

Parameters:
param  Usage : SUMA ( )
Returns :
Returns:
Support :
See also:
OpenGL prog. Guide 3rd edition , varray.c from book's sample code
Side effects :

Definition at line 6 of file iotest.c.

References argc, IOCHAN::bad, COX_clock_time(), iochan_clearcheck(), IOCHAN_CLOSE, iochan_goodcheck(), iochan_init(), iochan_readcheck(), iochan_recvall(), iochan_sendall(), iochan_writecheck(), malloc, RDEL, and WDEL.

00007 {
00008    IOCHAN * ioc ;
00009    int writer , ii , jj , kk , nbytes,nreps ;
00010    char * buf ;
00011    double time1,time2,rate ;
00012 
00013    if( argc < 5 ){
00014       printf("Usage: iotest iochan_spec mode_spec nbytes nreps\n");
00015       printf("where iochan_spec = shm:name:size or tcp:host:port\n");
00016       printf("      mode        = w or r\n") ;
00017       exit(0);
00018    }
00019 
00020    writer = (strcmp(argv[2],"create") == 0 || strcmp(argv[2],"w") == 0) ;
00021 
00022    nbytes = strtol( argv[3] , NULL , 10 ) ;
00023    if( nbytes < 2 ){fprintf(stderr,"nbytes is bad!\n");exit(1);}
00024    nreps  = strtol( argv[4] , NULL , 10 ) ;
00025    if( nreps  < 1 ){fprintf(stderr,"nreps is bad!\n");exit(1);}
00026    buf = (char *) malloc(nbytes) ;
00027 
00028    ioc = iochan_init( argv[1] , argv[2] ) ;
00029    if( ioc == NULL ){ printf("Error on creation of IOCHAN\n") ; exit(1) ; }
00030 
00031    printf("iochan_init returns ioc->bad = %d\n",ioc->bad) ;
00032 
00033    while( ! iochan_goodcheck(ioc,1000) ){
00034       printf(".") ; fflush(stdout) ;
00035    }
00036    printf("\nConnected\n") ;
00037 
00038    time1 = COX_clock_time() ;
00039    if( writer ){
00040       for( kk=0 ; kk < nreps ; kk++ ){
00041          while(1){
00042             jj = iochan_writecheck(ioc,WDEL) ;  /* check if ready */
00043             if( jj > 0 ) break ;
00044             if( jj < 0 ){ printf("\nIOCHAN is now bad!\n"); goto done;}
00045             printf(".") ; fflush(stdout) ;
00046          }
00047          iochan_sendall( ioc , buf , nbytes ) ;
00048          if( kk%10 == 0 ){printf("!") ; fflush(stdout) ;}
00049       }
00050       while( ! iochan_clearcheck(ioc,WDEL) ){ printf("c"); fflush(stdout); }
00051    } else {
00052       time1 = COX_clock_time() ;
00053       for( kk=0 ; kk < nreps ; kk++ ){
00054          while(1){
00055             jj = iochan_readcheck(ioc,RDEL) ;  /* check if ready */
00056             if( jj > 0 ) break ;
00057             if( jj < 0 ){ printf("\nIOCHAN is now bad!\n"); goto done; }
00058             printf(".") ; fflush(stdout) ;
00059          }
00060          ii = iochan_recvall( ioc , buf , nbytes ) ;
00061          if( kk%10 == 0 ){printf("!") ; fflush(stdout) ;}
00062       }
00063    }
00064 
00065 done:
00066    time2 = COX_clock_time() - time1 ;
00067    rate  = 0.001 * nbytes * nreps / time2 ;
00068    printf("\n%f K/sec\n",rate) ;
00069    IOCHAN_CLOSE(ioc) ;
00070    exit(0) ;
00071 }
 

Powered by Plone

This site conforms to the following standards: