added benchmarking script, some speedup (7029.54/s vs 5829.19/s),
[Biblio-Isis] / scripts / bench.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4 use blib;
5
6 use IsisDB;
7 use OpenIsis;
8 use MARC::File::USMARC;
9
10 use Benchmark qw( timethese cmpthese ) ;
11
12 my $isisdb = shift @ARGV || '/data/isis_data/ps/LIBRI/LIBRI';
13
14 my $isis = IsisDB->new (
15         isisdb => $isisdb,
16         debug => shift @ARGV,
17 );
18
19 my $rows = $isis->{'maxmfn'};
20
21 my $db = OpenIsis::open( $isisdb );
22
23 print "rows: $rows\n\n";
24
25 my $mfn = 1;
26
27 my $r = timethese( -5, {
28         IsisDB => sub {
29                 $isis->fetch( $mfn++ % $rows + 1 );
30         },
31         OpenIsis => sub {
32                 OpenIsis::read( $db, $mfn++ % $rows + 1 );
33         },
34 } );
35 cmpthese $r;
36