Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Problems with SDBM

by Tux (Monsignor)
on Mar 15, 2013 at 14:29 UTC ( #1023711=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Problems with SDBM
in thread Problems with SDBM

New actual numbers (higher is better), now include BerkeleyDB:

updated with *DBM_File columns (compressed the output a bit to make it "fit")

Linux 3.4.33-2.24-desktop [openSUSE 12.2 (Mantis)] i386 Core(TM) i7-2 +620M CPU @ 2.70GHz/800(4) i686 7969 Mb This is perl 5, version 16, subversion 3 (v5.16.3) built for i686-linu +x-64int Size op GDBM NDBM ODBM SDBM DB_File CDB_File BerkDB Re +dis Redis2 SQLite Pg mysql CSV ------ -- ------- ------- ------- ------- ------- -------- ------- --- +--- ------ ------- ------- ------- ------- 20 rd 32573 27972 27855 165289 24752 1111111 18587 4 +754 7186 30257 6197 3003 883 20 wr 19685 10678 9182 20855 6361 26917 5762 4 +848 6289 11961 2107 723 953 200 rd 142959 113636 116822 161550 62092 1333333 53404 5 +033 7507 37943 6312 1143 124 200 wr 65189 54555 64578 89007 58479 221483 37800 7 +700 8325 25687 4092 1417 230 600 rd 155925 114832 120992 183486 49285 1263157 43687 6 +366 7551 37657 11386 428 - 600 wr 101437 71633 83148 109950 44886 444115 41649 8 +717 6311 27700 5081 670 - 2000 rd 156311 97092 102202 138169 44295 1006036 39761 6 +209 8277 34599 10931 142 - 2000 wr 100376 76438 82474 107060 40711 577700 39096 8 +724 12205 27475 6241 260 - 20000 rd 141094 92384 94677 123507 49629 693096 43771 6 +098 8201 30522 9721 - - 20000 wr 94704 76299 80329 103297 30815 527676 29369 8 +284 8595 23866 5667 - - 200000 rd 134909 110688 99839 138195 45577 677541 40508 5 +385 7658 30463 8482 - - 200000 wr 51296 58657 59119 99944 28033 592327 26488 7 +949 9728 22878 5160 - -

Below is the script I run

#!/pro/bin/perl use strict; use warnings; sub usage { my $err = shift and select STDERR; print "usage: $0 [--verbose[=<level>]] [--fast | --long]\n"; exit $err; } # usage use Getopt::Long qw(:config bundling nopermute); my $opt_v = 1; my $opt_f = 0; my $opt_l = 0; GetOptions ( "help|?" => sub { usage (0); }, "v|verbose:2" => \$opt_v, "f|s|fast|short!" => \$opt_f, "l|long|slow!" => \$opt_l, ) or usage (1); use Data::Peek; use DB_File; use CDB_File; use Tie::Hash::DBD; eval "use Redis::Hash"; my $DB_CREATE = eval "use BerkeleyDB; DB_CREATE;"; use Time::HiRes qw( gettimeofday tv_interval ); my %t; my @conf = ( # [ "SDBM", "SDBM_File", "db.5", O_RDWR|O_CREAT, 0666 + ], [ "DB_File", "DB_File", "db.2", O_RDWR|O_CREAT, 0666 + ], [ "CDB_File","CDB_File", "db.3" + ], [ "Berkeley","BerkeleyDB::Hash", -Filename => "db.4", -Flags => $DB_CREATE, + ], [ "Redis", "Redis::Hash", "dbd_" + ], [ "Redis2", "Redis::Hash", "dbd2_", encoding => undef + ], [ "SQLite", "Tie::Hash::DBD", "dbi:SQLite:dbname=db.1" + ], [ "Pg", "Tie::Hash::DBD", "dbi:Pg:" + ], [ "mysql", "Tie::Hash::DBD", "dbi:mysql:database=merijn" + ], [ "CSV", "Tie::Hash::DBD", "dbi:CSV:f_ext=.csv/r;csv_null=1" + ], [ "Oracle", "Tie::Hash::DBD", "dbi:Oracle:" + ], [ "Unify", "Tie::Hash::DBD", "dbi:Unify:" + ], ); unlink $_ for glob ("db.[0-9]*"), glob ("t_tie*.csv"); foreach my $r (@conf) { my ($name, $pkg, @args, %hash) = @$r; if ($name eq "Oracle") { -d ($ENV{ORACLE_HOME} || "\x01") or next; $ENV{DBI_USER} = "UUU"; $ENV{DBI_PASS} = "PPP"; } if ($name eq "Unify") { -d ($ENV{UNIFY} || "\x01") or next; -d ($ENV{DBPATH} || "\x01") or next; $ENV{USCHEMA} = "SSS"; $ENV{DBI_USER} = "UUU"; $ENV{DBI_PASS} = undef; } eval { tie %hash, $pkg, @args }; if ($@) { warn $@; next; } foreach my $size (10, 100, 300, 1000, 10000, 100000) { $opt_f && $size > 300 and next; $opt_l || $size < 50000 or next; print STDERR " $name $size \r"; my %plain = map { ( $_ => $_ ) } map { ( $_, pack "l", $_ ) } -($size - 1) .. $size; %hash = (); my $s_size = 2 * $size; my $t0 = [ gettimeofday ]; %hash = %plain; my $elapsed = tv_interval ($t0); $t{$s_size}{wr}{$name} = $s_size / $elapsed; $t0 = [ gettimeofday ]; my %x = %hash; $elapsed = tv_interval ($t0); $t{$s_size}{rd}{$name} = $s_size / $elapsed; $t{$s_size}{rd}{$name} < 275 and last; # Next size will take t +oo long } %hash = (); untie %hash; } my @name = map { $_->[0] } grep { $t{20}{rd}{$_->[0]} } @conf; print " Size op", (map { sprintf " %7s", $_ } @name), "\n", "------ --", (map { " -------" } @name), "\n"; foreach my $size (sort { $a <=> $b } keys %t) { my %o = %{$t{$size}}; foreach my $op (sort keys %o) { printf "%6d %s", $size, $op; for (@name) { if (my $x = $o{$op}{$_}) { printf " %7.0f", $x; } else { print " -"; } } print "\n"; } }

Enjoy, Have FUN! H.Merijn
help|?


Comment on Re^3: Problems with SDBM
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1023711]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-08-20 07:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (106 votes), past polls