home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctech / 1988_02 / auto1.c next >
Text File  |  1985-08-21  |  3KB  |  112 lines

  1. /* auto1.c -  Automatic benchmark controller  */
  2. #include "stdio.h"
  3. static char *pname = "LPT1" ;
  4.  
  5. int nblock = 8096 ;
  6. char *inname , *outname ;
  7. FILE *prtfile ;
  8. FILE *fopen() ;
  9.  
  10. int float1() , funcall() ,  pscopy() , ccount() , gpfile() ;
  11. int bgpfile() ;
  12. int sieve() , rwfile() , siever() , penregs() ;
  13. int explog() , sintan() ;
  14. int dofib() ;
  15. int imath() , lmath() ;
  16.  
  17. main(argc,argv)
  18.  int argc ;
  19.  char *argv[] ;
  20.  {
  21.    int t ;
  22.  
  23.     if( argc < 2 )
  24.      { fprintf(stderr," *** need Compiler name \n");
  25.        exit(2) ;
  26.      }
  27.      
  28.    prtfile = fopen(pname,"w") ;
  29.    if( prtfile == NULL )
  30.      { fprintf(stderr,"\n\n *** can't open <%s> *** \n",pname) ;
  31.        exit(5) ;
  32.      }
  33.  
  34.    printf(" Compiler = %s \n\n",argv[1] ) ;
  35.    fprintf(prtfile,"\n Compiler = %s \n\n",argv[1] ) ;
  36.     t = runit(float1,20,"float dot prod. ") ;
  37.     if( t < 180 )
  38.             runit(float1,400,"float dot prod. ") ;
  39.     runit(funcall,20,"function calls ") ;
  40.     runit(pscopy,20,"ptr. str. copy ") ;
  41.     runit(ccount,20,"char count ") ;
  42.     inname = "a:test.in" ; outname = "a:test.out" ;
  43.     delfile() ;
  44.     runit(gpfile,2,"getc/putc file copy a:->a:") ;
  45.     inname = "c:test.in" ; outname = "c:test.out" ;
  46.     delfile() ;
  47.     runit(gpfile,2,"getc/putc copy c:->c:") ;
  48.  
  49.     runit(sieve,20,"sieve ") ;
  50.  
  51.     inname = "a:test.in" ; outname = "a:test.out" ;
  52.     nblock = 1024 ;
  53.     delfile() ;
  54.     printf("\n Read/Write file Copy\n");
  55.     fprintf(prtfile,"\n Read/Write file Copy\n");
  56.     runit(rwfile,1,"   block= 1024   a:->a:") ;
  57.     inname = "c:test.in" ; outname = "c:test.out" ;
  58.     nblock = 1024 ;
  59.     delfile() ;
  60.     runit(rwfile,1,"   block= 1024   c:->c:") ;
  61.  
  62.  
  63.     inname = "a:test.in" ; outname = "a:test.out" ;
  64.     delfile() ;
  65.     nblock = 8096 ;
  66.     runit(rwfile,1,"   block= 8096   a:->a:") ;
  67.  
  68.     inname = "c:test.in" ; outname = "c:test.out" ;
  69.     delfile() ;
  70.     nblock = 8096 ;
  71.     runit(rwfile,1,"   block= 8096   c:->c:") ;
  72.  
  73.     runit(siever,100,"sieve with reg. var. ") ;
  74.     runit(penregs,100,"str copy & reg var ") ;
  75.     runit(imath,20,"integer arithmetic ") ;
  76.     runit(lmath,20,"long arithmetic ") ;
  77.     t = runit(explog,10,"math - exp and log ") ;
  78.     if( t < 180 )
  79.           runit(explog,100,"math - exp and log ") ;
  80.     t = runit(sintan,10,"math - sin and tan ") ;
  81.     if( t < 180 )
  82.         runit(sintan,100,"math - sin and tan ") ;
  83.     runit(dofib,20,"fibernacci(15) ") ;
  84.  
  85.    fclose(prtfile) ;
  86.  }
  87.  
  88.  
  89. int runit(pfun,niter,benname)
  90.  int (*pfun)() ;
  91.  int niter ;
  92.  char *benname ;
  93.  {
  94.     int t , i ;
  95.  
  96.    eltime() ;
  97.    for( i=1 ; i <= niter ; i=i+1 )
  98.       { (*pfun) () ; }
  99.    t = eltime() ;
  100.     printf(" %-30s (%4d Iter.) - %4d Ticks or %8.2f Seconds \n",
  101.        benname, niter, t , ( (float) t) / 18.2 ) ;
  102.     fprintf(prtfile,"\n %-30s (%4d Iter.) - %4d Ticks or %8.2f Seconds ",
  103.        benname, niter, t , ( (float) t) / 18.2 ) ;
  104.      return(t) ;
  105.  }
  106.  
  107. delfile()
  108.  {
  109.     unlink(outname) ;
  110.  }
  111.  
  112.