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