File: gdbm.b

package info (click to toggle)
libapache-session-perl 1.94-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 448 kB
  • sloc: perl: 1,514; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 668 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl -w

use GDBM_File;
use Benchmark;

use vars qw(%hash $n);
$n = 0;

tie %hash, 'GDBM_File', '/tmp/foo.gdbm', &GDBM_WRCREAT, 0640;

sub insert {
	$hash{$n} = "A"x2**10;
	$n++;
}

sub access {
	my $this = $hash{int(rand($n-1))};
}
	
timethis(10000, \&insert, 'First 10000');
timethis(10000, \&access, 'Random Access n=10000');
timethis(90000, \&insert, 'Pad to 100000');
timethis(10000, \&insert, 'Insert 100000-110000');
timethis(10000, \&access, 'Random Access n=110000');
timethis(990000, \&insert, 'Pad to 1000000');
timethis(10000, \&insert, 'Insert 1000000-1001000');
timethis(10000, \&access, 'Random Access n=1001000');