From: Richard Levitte Date: Fri, 30 Jun 2000 17:16:46 +0000 (+0000) Subject: Give the user the option to measure real time instead of user CPU time. X-Git-Tag: OpenSSL-engine-0_9_6-beta1~21^2~15 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4e74239ccac9eb74a9a9e5ede93ea7bc9c4d6622;p=oweals%2Fopenssl.git Give the user the option to measure real time instead of user CPU time. --- diff --git a/apps/speed.c b/apps/speed.c index 163d5237c2..7166606da7 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -102,9 +102,7 @@ #undef TIMES #endif -#ifndef TIMES #include -#endif #if defined(sun) || defined(__ultrix) #define _POSIX_SOURCE @@ -178,7 +176,7 @@ #define BUFSIZE ((long)1024*8+1) int run=0; -static double Time_F(int s); +static double Time_F(int s, int usertime); static void print_message(char *s,long num,int length); static void pkey_print_message(char *str,char *str2,long num,int bits,int sec); #ifdef SIGALRM @@ -202,40 +200,45 @@ static SIGRETTYPE sig_done(int sig) #define START 0 #define STOP 1 -static double Time_F(int s) +static double Time_F(int s, int usertime) { double ret; #ifdef TIMES - static struct tms tstart,tend; - - if (s == START) - { - times(&tstart); - return(0); - } - else + if (usertime) { - times(&tend); - ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ; - return((ret < 1e-3)?1e-3:ret); - } -#else /* !times() */ - static struct timeb tstart,tend; - long i; + static struct tms tstart,tend; - if (s == START) - { - ftime(&tstart); - return(0); + if (s == START) + { + times(&tstart); + return(0); + } + else + { + times(&tend); + ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ; + return((ret < 1e-3)?1e-3:ret); + } } else +#endif /* times() */ { - ftime(&tend); - i=(long)tend.millitm-(long)tstart.millitm; - ret=((double)(tend.time-tstart.time))+((double)i)/1000.0; - return((ret < 0.001)?0.001:ret); + static struct timeb tstart,tend; + long i; + + if (s == START) + { + ftime(&tstart); + return(0); + } + else + { + ftime(&tend); + i=(long)tend.millitm-(long)tstart.millitm; + ret=((double)(tend.time-tstart.time))+((double)i)/1000.0; + return((ret < 0.001)?0.001:ret); + } } -#endif } int MAIN(int, char **); @@ -345,6 +348,11 @@ int MAIN(int argc, char **argv) int dsa_doit[DSA_NUM]; int doit[ALGOR_NUM]; int pr_header=0; + int usertime=1; + +#ifndef TIMES + usertime=-1; +#endif apps_startup(); memset(results, 0, sizeof(results)); @@ -391,6 +399,8 @@ int MAIN(int argc, char **argv) argv++; while (argc) { + if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0)) + usertime = 0; #ifndef NO_MD2 if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1; else @@ -510,7 +520,7 @@ int MAIN(int argc, char **argv) else #endif { - BIO_printf(bio_err,"bad value, pick one of\n"); + BIO_printf(bio_err,"bad option or value, pick one of\n"); BIO_printf(bio_err,"md2 mdc2 md5 hmac sha1 rmd160\n"); #ifndef NO_IDEA BIO_printf(bio_err,"idea-cbc "); @@ -538,6 +548,10 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err,"\ndsa512 dsa1024 dsa2048\n"); #endif BIO_printf(bio_err,"idea rc2 des rsa blowfish\n"); + BIO_printf(bio_err,"\n"); + BIO_printf(bio_err,"Available options:\n"); + BIO_printf(bio_err,"\n"); + BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n"); goto end; } argc--; @@ -557,10 +571,13 @@ int MAIN(int argc, char **argv) for (i=0; i