scratch/x.pl
branchfops
changeset 57 e91f117472ed
parent 37 cb50d6c57439
equal deleted inserted replaced
56:e7938f859e2f 57:e91f117472ed
     3 use strict;
     3 use strict;
     4 use warnings;
     4 use warnings;
     5 use Crypt::CBC;
     5 use Crypt::CBC;
     6 use autodie qw(:all);
     6 use autodie qw(:all);
     7 use Benchmark qw(:all);
     7 use Benchmark qw(:all);
       
     8 use Digest::MD5 qw(md5);
       
     9 use Digest::SHA1 qw(sha1);
       
    10 use String::CRC32;
     8 use IO::Compress::Gzip qw(gzip $GzipError);
    11 use IO::Compress::Gzip qw(gzip $GzipError);
     9 use File::Temp;
    12 use File::Temp;
    10 
    13 
    11 my $tmp = File::Temp->new();
    14 my $tmp = File::Temp->new();
    12 warn "<< $tmp >>\n";
    15 warn "<< $tmp >>\n";
    16     -keysize => 16,
    19     -keysize => 16,
    17     -cipher => 'Blowfish',
    20     -cipher => 'Blowfish',
    18 ) or die;
    21 ) or die;
    19 $ENV{X} = "x";
    22 $ENV{X} = "x";
    20 
    23 
    21 @ARGV = qw(/boot/vmlinuz-2.6.32-5-amd64);
    24 @ARGV = qw(/boot/vmlinuz-2.6.32-5-amd64) if not @ARGV;
    22 my $text = join "" => <>;
    25 my $text = join "" => <>;
    23 
    26 
    24 say length $text;
    27 say length $text;
       
    28 
       
    29 cmpthese(500 => {
       
    30     'md5'     => sub { _md5($text) },
       
    31     'sha1'    => sub { _sha1($text) },
       
    32     'crc32'   => sub { _crc32($text) },
       
    33     }
       
    34 );
    25 
    35 
    26 cmpthese(30 => {
    36 cmpthese(30 => {
    27     'openssl' => sub { openssl($text) },
    37     'openssl' => sub { openssl($text) },
    28     'perlssl' => sub { perlssl($text) },
    38     'perlssl' => sub { perlssl($text) },
    29     }
    39     }
    57     open(my $out, "|gzip -1 >$tmp");
    67     open(my $out, "|gzip -1 >$tmp");
    58     print $out $_[0];
    68     print $out $_[0];
    59     close $out;
    69     close $out;
    60     die $? if $?
    70     die $? if $?
    61 }
    71 }
       
    72 
       
    73 sub _crc32 {
       
    74     my $x = crc32(shift);
       
    75 }
       
    76 
       
    77 sub _md5 {
       
    78     my $x = md5(shift);
       
    79 }
       
    80 
       
    81 sub _sha1 {
       
    82     my $x = sha1(shift);
       
    83 }