added benchmarking script, some speedup (7029.54/s vs 5829.19/s),
[Biblio-Isis] / scripts / bench.pl
diff --git a/scripts/bench.pl b/scripts/bench.pl
new file mode 100755 (executable)
index 0000000..e7e130b
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/perl -w
+
+use strict;
+use blib;
+
+use IsisDB;
+use OpenIsis;
+use MARC::File::USMARC;
+
+use Benchmark qw( timethese cmpthese ) ;
+
+my $isisdb = shift @ARGV || '/data/isis_data/ps/LIBRI/LIBRI';
+
+my $isis = IsisDB->new (
+       isisdb => $isisdb,
+       debug => shift @ARGV,
+);
+
+my $rows = $isis->{'maxmfn'};
+
+my $db = OpenIsis::open( $isisdb );
+
+print "rows: $rows\n\n";
+
+my $mfn = 1;
+
+my $r = timethese( -5, {
+       IsisDB => sub {
+               $isis->fetch( $mfn++ % $rows + 1 );
+       },
+       OpenIsis => sub {
+               OpenIsis::read( $db, $mfn++ % $rows + 1 );
+       },
+} );
+cmpthese $r;
+