"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/b/dbstore.b" (15 Sep 2009, 1197 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 strict;
    2 use Benchmark;
    3 use Apache::Session::Store::DB_File;
    4 
    5 use vars qw($rs $ws $n);
    6 
    7 my $dir = int(rand(10000));
    8 mkdir $dir, 0700;
    9 chdir $dir;
   10 
   11 $ws = {
   12     args => {FileName => 'bench.dbm'},
   13     data => {_session_id => 0},
   14     serialized => "A"x2**10
   15 };
   16 $rs = {
   17     args => {FileName => 'bench.dbm'},
   18     data => {_session_id => 0},
   19     serialized => "A"x2**10
   20 };
   21 
   22 sub insert {
   23     my $store = new Apache::Session::Store::DB_File;
   24     $store->insert($ws);
   25     $ws->{data}->{_session_id}++;
   26 }
   27 
   28 sub materialize {
   29     $rs->{data}->{_session_id} = int(rand($ws->{data}->{_session_id} - 1));
   30     my $store = new Apache::Session::Store::DB_File;
   31     $store->materialize($rs);
   32 }
   33 
   34 timethis(1000, \&insert, 'Insert First 1000');
   35 timethis(1000, \&materialize, 'Random Access n=1000');
   36 
   37 for (my $i = 0; $i < 9000; $i++) {
   38     &insert;
   39 }
   40 
   41 timethis(1000, \&insert, 'Insert 10000-11000');
   42 timethis(1000, \&materialize, 'Random Access n=11000');
   43 
   44 for (my $i = 0; $i < 89000; $i++) {
   45     &insert;
   46 }
   47 
   48 timethis(1000, \&insert, 'Insert 100000-101000');
   49 timethis(1000, \&materialize, 'Random Access n=101000');
   50 
   51 unlink './bench.dbm';
   52 chdir '..';
   53 rmdir $dir;