1 |
dpavlin |
7 |
#!/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 |
dpavlin |
14 |
my $isis_filter = IsisDB->new ( |
20 |
|
|
isisdb => $isisdb, |
21 |
|
|
debug => shift @ARGV, |
22 |
|
|
hash_filter => sub { |
23 |
|
|
my $v = shift; |
24 |
|
|
return lc($v); |
25 |
|
|
} |
26 |
|
|
); |
27 |
|
|
|
28 |
dpavlin |
32 |
my $rows = $isis->count; |
29 |
dpavlin |
7 |
|
30 |
|
|
my $db = OpenIsis::open( $isisdb ); |
31 |
|
|
|
32 |
|
|
print "rows: $rows\n\n"; |
33 |
|
|
|
34 |
|
|
my $mfn = 1; |
35 |
|
|
|
36 |
|
|
my $r = timethese( -5, { |
37 |
|
|
IsisDB => sub { |
38 |
|
|
$isis->fetch( $mfn++ % $rows + 1 ); |
39 |
|
|
}, |
40 |
dpavlin |
14 |
IsisDB_hash => sub { |
41 |
|
|
$isis->to_hash( $mfn++ % $rows + 1 ); |
42 |
|
|
}, |
43 |
|
|
IsisDB_hash_filter => sub { |
44 |
|
|
$isis_filter->to_hash( $mfn++ % $rows + 1 ); |
45 |
|
|
}, |
46 |
|
|
|
47 |
dpavlin |
7 |
OpenIsis => sub { |
48 |
|
|
OpenIsis::read( $db, $mfn++ % $rows + 1 ); |
49 |
|
|
}, |
50 |
dpavlin |
14 |
|
51 |
|
|
OpenIsis_hash => sub { |
52 |
|
|
my $row = OpenIsis::read( $db, $mfn++ % $rows + 1 ); |
53 |
|
|
my $rec; |
54 |
|
|
no strict 'refs'; |
55 |
|
|
foreach my $f (keys %{$row}) { |
56 |
|
|
foreach my $v (@{$row->{$f}}) { |
57 |
|
|
push @{$rec->{$f}}, OpenIsis::subfields($v); |
58 |
|
|
} |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
}, |
62 |
dpavlin |
7 |
} ); |
63 |
|
|
cmpthese $r; |
64 |
|
|
|