62 #if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
69 #include OPENSSL_UNISTD_IO
72 #ifndef OPENSSL_SYS_NETWARE
80 #include <sys/types.h>
81 #include <sys/times.h>
88 #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
93 #include <sys/timeb.h>
96 #if defined(sun) || defined(__ultrix)
99 #include <sys/param.h>
104 #define CAST_DEFAULT_OPTIONS
107 #define CAST_encrypt CAST_encrypt_normal
108 #define CAST_decrypt CAST_decrypt_normal
109 #define CAST_cbc_encrypt CAST_cbc_encrypt_normal
110 #undef HEADER_CAST_LOCL_H
118 #undef CAST_cbc_encrypt
119 #define CAST_encrypt CAST_encrypt_ptr
120 #define CAST_decrypt CAST_decrypt_ptr
121 #define CAST_cbc_encrypt CAST_cbc_encrypt_ptr
122 #undef HEADER_CAST_LOCL_H
130 #undef CAST_cbc_encrypt
131 #define CAST_encrypt CAST_encrypt_ptr2
132 #define CAST_decrypt CAST_decrypt_ptr2
133 #define CAST_cbc_encrypt CAST_cbc_encrypt_ptr2
134 #undef HEADER_CAST_LOCL_H
140 # ifndef _BSD_CLK_TCK_
143 # define HZ ((double)_BSD_CLK_TCK_)
146 # define HZ ((double)CLK_TCK)
150 #define BUFSIZE ((long)1024)
155 #if defined(__STDC__) || defined(sgi)
156 #define SIGRETTYPE void
158 #define SIGRETTYPE int
161 SIGRETTYPE sig_done(
int sig);
162 SIGRETTYPE sig_done(
int sig)
164 signal(SIGALRM,sig_done);
179 static struct tms tstart,tend;
189 ret=((double)(tend.tms_utime-tstart.tms_utime))/
HZ;
190 return((ret == 0.0)?1
e-6:ret);
193 static struct timeb tstart,tend;
204 i=(long)tend.millitm-(
long)tstart.millitm;
205 ret=((double)(tend.time-tstart.time))+((
double)i)/1000.0;
206 return((ret == 0.0)?1
e-6:ret);
212 #define print_name(name) fprintf(stderr,"Doing %s's for 10 seconds\n",name); alarm(10);
214 #define print_name(name) fprintf(stderr,"Doing %s %ld times\n",name,cb);
217 #define time_it(func,name,index) \
220 for (count=0,run=1; COND(cb); count+=4) \
222 unsigned long d[2]; \
228 tm[index]=Time_F(STOP); \
229 fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \
230 tm[index]=((double)COUNT(cb))/tm[index];
232 #define print_it(name,index) \
233 fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
234 tm[index]*8,1.0e6/tm[index]);
236 int main(
int argc,
char **argv)
239 static unsigned char buf[
BUFSIZE];
240 static char key[16]={ 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
241 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
243 double d,tm[16],
max=0;
246 int max_idx=0,i,
num=0,j;
258 fprintf(stderr,
"To get the most accurate results, try to run this\n");
259 fprintf(stderr,
"program when this computer is idle.\n");
265 fprintf(stderr,
"First we calculate the approximate speed ...\n");
269 unsigned long data[2];
273 for (i=count; i; i--)
283 #define COND(d) (count != (d))
286 #define COND(c) (run)
287 #define COUNT(d) (count)
288 signal(SIGALRM,sig_done);
292 time_it(CAST_encrypt_normal,
"CAST_encrypt_normal ", 0);
293 time_it(CAST_encrypt_ptr,
"CAST_encrypt_ptr ", 1);
294 time_it(CAST_encrypt_ptr2,
"CAST_encrypt_ptr2 ", 2);
303 if (max < tm[1]) { max=tm[1]; max_idx=1; }
306 if (max < tm[2]) { max=tm[2]; max_idx=2; }
308 printf(
"options CAST ecb/s\n");
309 printf(
"%s %12.2f 100.0%%\n",str[max_idx],tm[max_idx]);
317 if (max < tm[i]) { max=tm[i]; j=i; }
319 if (max < 0.0)
break;
320 printf(
"%s %12.2f %4.1f%%\n",str[j],tm[j],tm[j]/d*100.0);
328 printf(
"-DCAST_DEFAULT_OPTIONS\n");
331 printf(
"-DCAST_PTR\n");
334 printf(
"-DCAST_PTR2\n");
338 #if defined(LINT) || defined(OPENSSL_SYS_MSDOS)