X-Git-Url: http://git.rot13.org/?p=Biblio-Isis;a=blobdiff_plain;f=scripts%2Fbench.pl;h=dac926bff70ffdc2699ea126854732d692dda836;hp=e7e130b24a6893234ca11af9d626bf66801fbec5;hb=45fa9507148d930eda7cafc89d11dfb332af55e8;hpb=9988e13063704c30d494b59057e0652b32330143;ds=sidebyside diff --git a/scripts/bench.pl b/scripts/bench.pl index e7e130b..dac926b 100755 --- a/scripts/bench.pl +++ b/scripts/bench.pl @@ -3,7 +3,7 @@ use strict; use blib; -use IsisDB; +use Biblio::Isis; use OpenIsis; use MARC::File::USMARC; @@ -11,12 +11,21 @@ use Benchmark qw( timethese cmpthese ) ; my $isisdb = shift @ARGV || '/data/isis_data/ps/LIBRI/LIBRI'; -my $isis = IsisDB->new ( +my $isis = Biblio::Isis->new ( isisdb => $isisdb, debug => shift @ARGV, ); -my $rows = $isis->{'maxmfn'}; +my $isis_filter = Biblio::Isis->new ( + isisdb => $isisdb, + debug => shift @ARGV, + hash_filter => sub { + my $v = shift; + return lc($v); + } +); + +my $rows = $isis->count; my $db = OpenIsis::open( $isisdb ); @@ -25,12 +34,31 @@ print "rows: $rows\n\n"; my $mfn = 1; my $r = timethese( -5, { - IsisDB => sub { + Isis => sub { $isis->fetch( $mfn++ % $rows + 1 ); }, + Isis_hash => sub { + $isis->to_hash( $mfn++ % $rows + 1 ); + }, + Isis_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;