home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
pctech
/
feb88.arc
/
AUTO2.C
< prev
next >
Wrap
Text File
|
1985-09-30
|
2KB
|
119 lines
/* auto2.c - individual benchmark tests - (from pentath.c) */
#include "stdio.h"
FILE *fopen() ;
int float1() /* floating point arithmetic benchmark */
{
int i , j ;
float x[100] , y[100] , z ;
for( i=0 ; i < 100 ; i=i+1 )
{ x[i] = i+1 ;
y[i] = 3*i ;
} ;
z=0 ;
for( j=0 ; j < 10 ; j=j+1 )
{
for( i=0 ; i < 100 ; i=i+1 )
{ z = z + x[i]*y[i] ; } ;
}
}
int funcall() /* function calling benchmark */
{
int i ;
for( i=0 ; i < 20000 ; i=i+1 )
{ dummy(i) ; } ;
}
int dummy(i)
int i ;
{
return( i+1 ) ;
}
int pscopy() /* pointer based string copy benchmark */
{
int i ;
char s[501] , s2[501] ;
for(i=0 ; i < 500 ; i=i+1 )
{ s[i] = 'a' ; } ;
s[500] = '\0' ;
for( i=0 ; i < 100 ; i=i+1 )
{ scopy(s2,s) ; } ;
}
int scopy(to,from) /* string copy function */
char *to ; /* pointer to destination string */
char *from ; /* pointer to source string */
{
while( (*to++ = *from++) != '\0' ) /* check for end of string */
{ ; } ; /* copy one char and advance ptrs */
}
int ccount() /* character count benchmark */
{
int i ;
char s[501] ;
int cnt[128] ;
for(i=0 ; i < 500 ; i=i+1 )
{ s[i] = i + 1 ; } ;
s[500] = '\0' ;
for( i=0 ; i < 100 ; i=i+1 )
{ count_chars(s,cnt) ; } ;
}
int count_chars(string,counts)
char string[] ;
int counts[] ;
{
register int i ;
register char c ;
i=0 ;
c = string[i] ;
while( c != '\0' )
{ counts[ c & 0x7f ] ++ ;
i = i + 1 ;
c = string[i] ;
} ;
}
extern char *inname , *outname ;
int gpfile() /* file copy with getc/putc */
{
FILE *in ,
*out ;
int c ;
long n ;
in = fopen(inname,"r");
out = fopen(outname,"w");
if( (in == NULL) || (out ==NULL) )
{ printf("can't open a file");
exit(0) ;
}
n=0;
c = getc(in) ;
while( c != EOF )
{ n=n+1 ;
putc(c,out);
c = getc(in) ;
}
fclose(in);
fclose(out);
}