"Fossies" - the Fresh Open Source Software Archive

Member "Apache-Session-1.93/b/gdbm.b" (15 Sep 2009, 668 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 #!/usr/bin/perl -w
    2 
    3 use GDBM_File;
    4 use Benchmark;
    5 
    6 use vars qw(%hash $n);
    7 $n = 0;
    8 
    9 tie %hash, 'GDBM_File', '/tmp/foo.gdbm', &GDBM_WRCREAT, 0640;
   10 
   11 sub insert {
   12     $hash{$n} = "A"x2**10;
   13     $n++;
   14 }
   15 
   16 sub access {
   17     my $this = $hash{int(rand($n-1))};
   18 }
   19     
   20 timethis(10000, \&insert, 'First 10000');
   21 timethis(10000, \&access, 'Random Access n=10000');
   22 timethis(90000, \&insert, 'Pad to 100000');
   23 timethis(10000, \&insert, 'Insert 100000-110000');
   24 timethis(10000, \&access, 'Random Access n=110000');
   25 timethis(990000, \&insert, 'Pad to 1000000');
   26 timethis(10000, \&insert, 'Insert 1000000-1001000');
   27 timethis(10000, \&access, 'Random Access n=1001000');