From e1e9ead6fbccbb0e5a96d222d5d80cafc3de6117 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Fri, 30 Jun 2000 17:52:33 +0000 Subject: [PATCH] Merge in the latest changes from the main trunk, and extra in apps/speed.c --- apps/speed.c | 163 +++++++++++++++++++++++------------------- config | 2 +- crypto/rand/md_rand.c | 2 + doc/standards.txt | 20 +++++- 4 files changed, 113 insertions(+), 74 deletions(-) diff --git a/apps/speed.c b/apps/speed.c index 31a2c18a4e..8a6b295777 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -103,9 +103,7 @@ #undef TIMES #endif -#ifndef TIMES #include -#endif #if defined(sun) || defined(__ultrix) #define _POSIX_SOURCE @@ -179,7 +177,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 @@ -203,40 +201,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 **); @@ -347,6 +350,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)); @@ -393,7 +401,10 @@ int MAIN(int argc, char **argv) argv++; while (argc) { - if ((strcmp(*argv,"-engine") == 0) && (argc > 0)) + if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0)) + usertime = 0; + else + if ((argc > 0) && (strcmp(*argv,"-engine") == 0)) { argc--; argv++; @@ -542,7 +553,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 "); @@ -570,6 +581,11 @@ 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"); + BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n"); goto end; } argc--; @@ -589,10 +605,13 @@ int MAIN(int argc, char **argv) for (i=0; i