Stop thinking arguments starting with - are algorithm identifiers.

Show timing parameters and timing functions used.
It looks like some Linuxen have very weird settings for CLK_TCK.  I'm
very unsure about this change and will investigate further.
This commit is contained in:
Richard Levitte 2001-09-27 15:43:55 +00:00
parent 1a19f83d4c
commit 7876e4488f

View File

@ -1,4 +1,4 @@
/* apps/speed.c */ /* apps/speed.c -*- mode:C; c-file-style: "eay" -*- */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved. * All rights reserved.
* *
@ -188,7 +188,12 @@
# define HZ ((double)_BSD_CLK_TCK_) # define HZ ((double)_BSD_CLK_TCK_)
# endif # endif
# else /* CLK_TCK */ # else /* CLK_TCK */
# define HZ ((double)CLK_TCK) # ifdef OPENSSL_SYS_LINUX /* Because it seems like some Linuxen
have weird values here... */
# define HZ 100.0
# else
# define HZ ((double)CLK_TCK)
# endif
# endif # endif
#endif #endif
@ -196,6 +201,8 @@
#define BUFSIZE ((long)1024*8+1) #define BUFSIZE ((long)1024*8+1)
int run=0; int run=0;
static char ftime_used = 0, times_used = 0, gettimeofday_used = 0, getrusage_used = 0;
static double Time_F(int s, int usertime); static double Time_F(int s, int usertime);
static void print_message(const char *s,long num,int length); static void print_message(const char *s,long num,int length);
static void pkey_print_message(char *str,char *str2,long num,int bits,int sec); static void pkey_print_message(char *str,char *str2,long num,int bits,int sec);
@ -229,6 +236,7 @@ static double Time_F(int s, int usertime)
{ {
static struct rusage tstart,tend; static struct rusage tstart,tend;
getrusage_used = 1;
if (s == START) if (s == START)
{ {
getrusage(RUSAGE_SELF,&tstart); getrusage(RUSAGE_SELF,&tstart);
@ -250,6 +258,7 @@ static double Time_F(int s, int usertime)
static struct timeval tstart,tend; static struct timeval tstart,tend;
long i; long i;
gettimeofday_used = 1;
if (s == START) if (s == START)
{ {
gettimeofday(&tstart,NULL); gettimeofday(&tstart,NULL);
@ -270,6 +279,7 @@ static double Time_F(int s, int usertime)
{ {
static struct tms tstart,tend; static struct tms tstart,tend;
times_used = 1;
if (s == START) if (s == START)
{ {
times(&tstart); times(&tstart);
@ -291,6 +301,7 @@ static double Time_F(int s, int usertime)
static struct timeb tstart,tend; static struct timeb tstart,tend;
long i; long i;
ftime_used = 1;
if (s == START) if (s == START)
{ {
ftime(&tstart); ftime(&tstart);
@ -477,7 +488,11 @@ int MAIN(int argc, char **argv)
while (argc) while (argc)
{ {
if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0)) if ((argc > 0) && (strcmp(*argv,"-elapsed") == 0))
{
usertime = 0; usertime = 0;
j--; /* Otherwise, -elapsed gets confused with
an algorithm. */
}
else if ((argc > 0) && (strcmp(*argv,"-evp") == 0)) else if ((argc > 0) && (strcmp(*argv,"-evp") == 0))
{ {
argc--; argc--;
@ -495,10 +510,13 @@ int MAIN(int argc, char **argv)
} }
doit[D_EVP]=1; doit[D_EVP]=1;
} }
else if(argc > 0 && !strcmp(*argv,"-decrypt")) else if (argc > 0 && !strcmp(*argv,"-decrypt"))
{
decrypt=1; decrypt=1;
else j--; /* Otherwise, -elapsed gets confused with
if ((argc > 0) && (strcmp(*argv,"-engine") == 0)) an algorithm. */
}
else if ((argc > 0) && (strcmp(*argv,"-engine") == 0))
{ {
argc--; argc--;
argv++; argv++;
@ -1416,6 +1434,30 @@ int MAIN(int argc, char **argv)
printf("%s ",BF_options()); printf("%s ",BF_options());
#endif #endif
fprintf(stdout,"\n%s\n",SSLeay_version(SSLEAY_CFLAGS)); fprintf(stdout,"\n%s\n",SSLeay_version(SSLEAY_CFLAGS));
printf("available timing options: ");
#ifdef TIMES
printf("TIMES ");
#endif
#ifdef TIMEB
printf("TIMEB ");
#endif
#ifdef USE_TOD
printf("USE_TOD ");
#endif
#ifdef HZ
#define as_string(s) (#s)
printf("HZ=%g", (double)HZ);
#endif
printf("\n");
printf("timing function used: %s%s%s%s%s%s%s\n",
(ftime_used ? "ftime" : ""),
(ftime_used + times_used > 1 ? "," : ""),
(times_used ? "times" : ""),
(ftime_used + times_used + gettimeofday_used > 1 ? "," : ""),
(gettimeofday_used ? "gettimeofday" : ""),
(ftime_used + times_used + gettimeofday_used + getrusage_used > 1 ? "," : ""),
(getrusage_used ? "getrusage" : ""));
if (pr_header) if (pr_header)
{ {