X-Git-Url: http://git.rot13.org/?p=Biblio-Isis;a=blobdiff_plain;f=scripts%2Fbench.pl;h=4fd3cb2bd3fe4e311e05be4547831cf125d69bc7;hp=e7e130b24a6893234ca11af9d626bf66801fbec5;hb=c9611dfe337a4eb721fba8629672c725d7bec729;hpb=9988e13063704c30d494b59057e0652b32330143 diff --git a/scripts/bench.pl b/scripts/bench.pl index e7e130b..4fd3cb2 100755 --- a/scripts/bench.pl +++ b/scripts/bench.pl @@ -16,7 +16,16 @@ my $isis = IsisDB->new ( debug => shift @ARGV, ); -my $rows = $isis->{'maxmfn'}; +my $isis_filter = IsisDB->new ( + isisdb => $isisdb, + debug => shift @ARGV, + hash_filter => sub { + my $v = shift; + return lc($v); + } +); + +my $rows = $isis->count; my $db = OpenIsis::open( $isisdb ); @@ -28,9 +37,28 @@ my $r = timethese( -5, { IsisDB => sub { $isis->fetch( $mfn++ % $rows + 1 ); }, + IsisDB_hash => sub { + $isis->to_hash( $mfn++ % $rows + 1 ); + }, + IsisDB_hash_filter => sub { + $isis_filter->to_hash( $mfn++ % $rows + 1 ); + }, + OpenIsis => sub { OpenIsis::read( $db, $mfn++ % $rows + 1 ); }, + + OpenIsis_hash => sub { + my $row = OpenIsis::read( $db, $mfn++ % $rows + 1 ); + my $rec; + no strict 'refs'; + foreach my $f (keys %{$row}) { + foreach my $v (@{$row->{$f}}) { + push @{$rec->{$f}}, OpenIsis::subfields($v); + } + } + + }, } ); cmpthese $r;