1*ebfedea0SLionel Sambuc#!/usr/local/bin/perl 2*ebfedea0SLionel Sambuc# 3*ebfedea0SLionel Sambuc# This file takes as input, the files that have been output from 4*ebfedea0SLionel Sambuc# ssleay speed. 5*ebfedea0SLionel Sambuc# It prints a table of the relative differences with %100 being 'no difference' 6*ebfedea0SLionel Sambuc# 7*ebfedea0SLionel Sambuc 8*ebfedea0SLionel Sambuc($#ARGV == 1) || die "$0 speedout1 speedout2\n"; 9*ebfedea0SLionel Sambuc 10*ebfedea0SLionel Sambuc%one=&loadfile($ARGV[0]); 11*ebfedea0SLionel Sambuc%two=&loadfile($ARGV[1]); 12*ebfedea0SLionel Sambuc 13*ebfedea0SLionel Sambuc$line=0; 14*ebfedea0SLionel Sambucforeach $a ("md2","md4","md5","sha","sha1","rc4","des cfb","des cbc","des ede3", 15*ebfedea0SLionel Sambuc "idea cfb","idea cbc","rc2 cfb","rc2 cbc","blowfish cbc","cast cbc") 16*ebfedea0SLionel Sambuc { 17*ebfedea0SLionel Sambuc if (defined($one{$a,8}) && defined($two{$a,8})) 18*ebfedea0SLionel Sambuc { 19*ebfedea0SLionel Sambuc print "type 8 byte% 64 byte% 256 byte% 1024 byte% 8192 byte%\n" 20*ebfedea0SLionel Sambuc unless $line; 21*ebfedea0SLionel Sambuc $line++; 22*ebfedea0SLionel Sambuc printf "%-12s ",$a; 23*ebfedea0SLionel Sambuc foreach $b (8,64,256,1024,8192) 24*ebfedea0SLionel Sambuc { 25*ebfedea0SLionel Sambuc $r=$two{$a,$b}/$one{$a,$b}*100; 26*ebfedea0SLionel Sambuc printf "%12.2f",$r; 27*ebfedea0SLionel Sambuc } 28*ebfedea0SLionel Sambuc print "\n"; 29*ebfedea0SLionel Sambuc } 30*ebfedea0SLionel Sambuc } 31*ebfedea0SLionel Sambuc 32*ebfedea0SLionel Sambucforeach $a ( 33*ebfedea0SLionel Sambuc "rsa 512","rsa 1024","rsa 2048","rsa 4096", 34*ebfedea0SLionel Sambuc "dsa 512","dsa 1024","dsa 2048", 35*ebfedea0SLionel Sambuc ) 36*ebfedea0SLionel Sambuc { 37*ebfedea0SLionel Sambuc if (defined($one{$a,1}) && defined($two{$a,1})) 38*ebfedea0SLionel Sambuc { 39*ebfedea0SLionel Sambuc $r1=($one{$a,1}/$two{$a,1})*100; 40*ebfedea0SLionel Sambuc $r2=($one{$a,2}/$two{$a,2})*100; 41*ebfedea0SLionel Sambuc printf "$a bits %% %6.2f %% %6.2f\n",$r1,$r2; 42*ebfedea0SLionel Sambuc } 43*ebfedea0SLionel Sambuc } 44*ebfedea0SLionel Sambuc 45*ebfedea0SLionel Sambucsub loadfile 46*ebfedea0SLionel Sambuc { 47*ebfedea0SLionel Sambuc local($file)=@_; 48*ebfedea0SLionel Sambuc local($_,%ret); 49*ebfedea0SLionel Sambuc 50*ebfedea0SLionel Sambuc open(IN,"<$file") || die "unable to open '$file' for input\n"; 51*ebfedea0SLionel Sambuc $header=1; 52*ebfedea0SLionel Sambuc while (<IN>) 53*ebfedea0SLionel Sambuc { 54*ebfedea0SLionel Sambuc $header=0 if /^[dr]sa/; 55*ebfedea0SLionel Sambuc if (/^type/) { $header=0; next; } 56*ebfedea0SLionel Sambuc next if $header; 57*ebfedea0SLionel Sambuc chop; 58*ebfedea0SLionel Sambuc @a=split; 59*ebfedea0SLionel Sambuc if ($a[0] =~ /^[dr]sa$/) 60*ebfedea0SLionel Sambuc { 61*ebfedea0SLionel Sambuc ($n,$t1,$t2)=($_ =~ /^([dr]sa\s+\d+)\s+bits\s+([.\d]+)s\s+([.\d]+)/); 62*ebfedea0SLionel Sambuc $ret{$n,1}=$t1; 63*ebfedea0SLionel Sambuc $ret{$n,2}=$t2; 64*ebfedea0SLionel Sambuc } 65*ebfedea0SLionel Sambuc else 66*ebfedea0SLionel Sambuc { 67*ebfedea0SLionel Sambuc $n=join(' ',grep(/[^k]$/,@a)); 68*ebfedea0SLionel Sambuc @k=grep(s/k$//,@a); 69*ebfedea0SLionel Sambuc 70*ebfedea0SLionel Sambuc $ret{$n, 8}=$k[0]; 71*ebfedea0SLionel Sambuc $ret{$n, 64}=$k[1]; 72*ebfedea0SLionel Sambuc $ret{$n, 256}=$k[2]; 73*ebfedea0SLionel Sambuc $ret{$n,1024}=$k[3]; 74*ebfedea0SLionel Sambuc $ret{$n,8192}=$k[4]; 75*ebfedea0SLionel Sambuc } 76*ebfedea0SLionel Sambuc } 77*ebfedea0SLionel Sambuc close(IN); 78*ebfedea0SLionel Sambuc return(%ret); 79*ebfedea0SLionel Sambuc } 80*ebfedea0SLionel Sambuc 81