From: Ben Laurie Date: Thu, 25 Oct 2001 14:27:17 +0000 (+0000) Subject: Add paralellism to speed - note that this currently causes a weird memory leak. X-Git-Tag: OpenSSL_0_9_6c~26^2~87 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=0e211563335b58e6d16079acc347395dbcc81f91;ds=inline Add paralellism to speed - note that this currently causes a weird memory leak. --- diff --git a/CHANGES b/CHANGES index 5c6a9fdcdd..cc418820d5 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,10 @@ *) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7 +) applies to 0.9.7 only + +) Add -multi and -mr options to "openssl speed" - giving multiple parallel + runs for the former and machine-readable output for the latter. + [Ben Laurie] + +) Add '-noemailDN' option to 'openssl ca'. This prevents inclusion of the e-mail address in the DN (i.e., it will go into a certificate extension only). The new configuration file option 'email_in_dn = no' diff --git a/apps/speed.c b/apps/speed.c index b5e4e0e90a..de35c47e47 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -202,10 +202,14 @@ int run=0; static char ftime_used = 0, times_used = 0, gettimeofday_used = 0, getrusage_used = 0; +static int mr=0; +static int usertime=1; -static double Time_F(int s, int usertime); +static double Time_F(int s); 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 print_result(int alg,int run_no,int count,double time_used); +static int do_multi(int multi); #ifdef SIGALRM #if defined(__STDC__) || defined(sgi) || defined(_AIX) #define SIGRETTYPE void @@ -213,6 +217,19 @@ static void pkey_print_message(char *str,char *str2,long num,int bits,int sec); #define SIGRETTYPE int #endif +#define ALGOR_NUM 16 +#define SIZE_NUM 5 +#define RSA_NUM 4 +#define DSA_NUM 3 +static const char *names[ALGOR_NUM]={ + "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4", + "des cbc","des ede3","idea cbc", + "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc"}; +static double results[ALGOR_NUM][SIZE_NUM]; +static int lengths[SIZE_NUM]={8,64,256,1024,8*1024}; +static double rsa_results[RSA_NUM][2]; +static double dsa_results[DSA_NUM][2]; + static SIGRETTYPE sig_done(int sig); static SIGRETTYPE sig_done(int sig) { @@ -227,7 +244,7 @@ static SIGRETTYPE sig_done(int sig) #define START 0 #define STOP 1 -static double Time_F(int s, int usertime) +static double Time_F(int s) { double ret; @@ -326,10 +343,6 @@ int MAIN(int argc, char **argv) ENGINE *e; unsigned char *buf=NULL,*buf2=NULL; int mret=1; -#define ALGOR_NUM 16 -#define SIZE_NUM 5 -#define RSA_NUM 4 -#define DSA_NUM 3 long count,rsa_count,save_count=0; int i,j,k; #ifndef OPENSSL_NO_RSA @@ -401,13 +414,8 @@ int MAIN(int argc, char **argv) #define D_CBC_BF 13 #define D_CBC_CAST 14 #define D_EVP 15 - double d,results[ALGOR_NUM][SIZE_NUM]; - static int lengths[SIZE_NUM]={8,64,256,1024,8*1024}; + double d; long c[ALGOR_NUM][SIZE_NUM]; - static const char *names[ALGOR_NUM]={ - "md2","mdc2","md4","md5","hmac(md5)","sha1","rmd160","rc4", - "des cbc","des ede3","idea cbc", - "rc2 cbc","rc5-32/12 cbc","blowfish cbc","cast cbc"}; #define R_DSA_512 0 #define R_DSA_1024 1 #define R_DSA_2048 2 @@ -418,7 +426,6 @@ int MAIN(int argc, char **argv) #ifndef OPENSSL_NO_RSA RSA *rsa_key[RSA_NUM]; long rsa_c[RSA_NUM][2]; - double rsa_results[RSA_NUM][2]; static unsigned int rsa_bits[RSA_NUM]={512,1024,2048,4096}; static unsigned char *rsa_data[RSA_NUM]= {test512,test1024,test2048,test4096}; @@ -429,16 +436,15 @@ int MAIN(int argc, char **argv) #ifndef OPENSSL_NO_DSA DSA *dsa_key[DSA_NUM]; long dsa_c[DSA_NUM][2]; - double dsa_results[DSA_NUM][2]; static unsigned int dsa_bits[DSA_NUM]={512,1024,2048}; #endif int rsa_doit[RSA_NUM]; int dsa_doit[DSA_NUM]; int doit[ALGOR_NUM]; int pr_header=0; - int usertime=1; const EVP_CIPHER *evp=NULL; int decrypt=0; + int multi=0; #ifndef TIMES usertime=-1; @@ -534,6 +540,28 @@ int MAIN(int argc, char **argv) means all of them should be run) */ j--; } + else if ((argc > 0) && (strcmp(*argv,"-multi") == 0)) + { + argc--; + argv++; + if(argc == 0) + { + BIO_printf(bio_err,"no multi count given\n"); + goto end; + } + multi=atoi(argv[0]); + if(multi <= 0) + { + BIO_printf(bio_err,"bad multi count\n"); + goto end; + } + } + else if (argc > 0 && !strcmp(*argv,"-mr")) + { + mr=1; + j--; /* Otherwise, -mr gets confused with + an algorithm. */ + } else #ifndef OPENSSL_NO_MD2 if (strcmp(*argv,"md2") == 0) doit[D_MD2]=1; @@ -746,6 +774,10 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err,"-elapsed measure time in real time instead of CPU user time.\n"); #endif BIO_printf(bio_err,"-engine e use engine e, possibly a hardware device.\n"); + BIO_printf(bio_err,"-evp e use EVP e.\n"); + BIO_printf(bio_err,"-decrypt time decryption instead of encryption (only EVP).\n"); + BIO_printf(bio_err,"-mr produce machine readable output.\n"); + BIO_printf(bio_err,"-multi n run n benchmarks in parallel.\n"); goto end; } argc--; @@ -753,6 +785,9 @@ int MAIN(int argc, char **argv) j++; } + if(multi && do_multi(multi)) + goto show_res; + if (j == 0) { for (i=0; in)); + BIO_printf(bio_err,mr ? "+RK:%d:" + : "Loaded RSA key, %d bit modulus and e= 0x", + BN_num_bits(rsa_key[i]->n)); BN_print(bio_err,rsa_key[i]->e); BIO_printf(bio_err,"\n"); } @@ -842,7 +879,7 @@ int MAIN(int argc, char **argv) for (i=count; i; i--) des_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock, &sch,DES_ENCRYPT); - d=Time_F(STOP,usertime); + d=Time_F(STOP); } while (d <3); save_count=count; c[D_MD2][0]=count/10; @@ -944,13 +981,11 @@ int MAIN(int argc, char **argv) for (j=0; j 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" : "")); - + 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) { - fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n"); - fprintf(stdout,"type "); + if(mr) + fprintf(stdout,"+H"); + else + { + fprintf(stdout,"The 'numbers' are in 1000s of bytes per second processed.\n"); + fprintf(stdout,"type "); + } for (j=0; j 10000) + if (results[k][j] > 10000 && !mr) fprintf(stdout," %11.2fk",results[k][j]/1e3); else - fprintf(stdout," %11.2f ",results[k][j]); + fprintf(stdout,mr ? ":%.2f" : " %11.2f ",results[k][j]); } fprintf(stdout,"\n"); } @@ -1494,15 +1509,19 @@ int MAIN(int argc, char **argv) for (k=0; k