File: bench.pl

package info (click to toggle)
libbiblio-isis-perl 0.24-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 364 kB
  • sloc: perl: 642; makefile: 2
file content (64 lines) | stat: -rwxr-xr-x 1,086 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/perl -w

use strict;
use blib;

use Biblio::Isis;
use OpenIsis;
use MARC::File::USMARC;

use Benchmark qw( timethese cmpthese ) ;

my $isisdb = shift @ARGV || '/data/isis_data/ps/LIBRI/LIBRI';

my $isis = Biblio::Isis->new (
	isisdb => $isisdb,
	debug => shift @ARGV,
);

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 );

print "rows: $rows\n\n";

my $mfn = 1;

my $r = timethese( -5, {
	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;