sp-diff.pl 1.6 KB

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