"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/b/uuevsmime.b" (15 Sep 2009, 1394 Bytes) of package /linux/www/Apache-Session-1.93.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Limbo source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 use Benchmark;
    2 use Apache::Session::Serialize::UUEncode;
    3 use Apache::Session::Serialize::Base64;
    4 use Apache::Session::Serialize::Storable;
    5 
    6 use vars qw($hash);
    7 
    8 $hash = { 
    9     serialized => undef, 
   10     data => {
   11         foo => 'A'x32,
   12         bar => [1,2,3,4,5,6,7,8,9,0],
   13         baz => {
   14             blah => 'A'x32,
   15             bleh => 'B'x32
   16         }
   17     }
   18 };
   19 
   20 sub uue {
   21     my $z = Apache::Session::Serialize::UUEncode::serialize($hash);
   22     Apache::Session::Serialize::UUEncode::unserialize($hash);
   23 }
   24 
   25 sub base64 {
   26     my $z = Apache::Session::Serialize::Base64::serialize($hash);
   27     Apache::Session::Serialize::Base64::unserialize($hash);
   28 }
   29 
   30 sub storable {
   31     my $z = Apache::Session::Serialize::Storable::serialize($hash);
   32     Apache::Session::Serialize::Storable::unserialize($hash);
   33 }
   34 
   35 timethese(-3, {
   36     Base64   => \&base64,
   37     UUE      => \&uue,
   38     Storable => \&storable
   39 });
   40 
   41 $hash->{data}->{foo} = 'A'x32000;
   42 
   43 timethese(-3, {
   44     'Big Base64'   => \&base64,
   45     'Big UUE'      => \&uue,
   46     'Big Storable' => \&storable,
   47 });
   48 
   49 print "Length with UUE: ". length(Apache::Session::Serialize::UUEncode::serialize($hash)) ."\n";
   50 print "Length with Base64: ". length(Apache::Session::Serialize::Base64::serialize($hash)) ."\n";
   51 print "Length with Storable: ". length(Apache::Session::Serialize::Storable::serialize($hash)) ."\n";