--- trunk/t/6-unit.t 2006/05/13 12:08:05 474 +++ trunk/t/6-unit.t 2006/05/14 12:35:10 489 @@ -2,12 +2,13 @@ use strict; -use Test::More tests => 66; +use Test::More tests => 41; use Test::Exception; use Cwd qw/abs_path/; use File::Temp qw/tempdir/; use File::Slurp; use Data::Dumper; +use Time::HiRes qw/time/; use blib; my $debug = shift @ARGV; @@ -26,13 +27,16 @@ diag "abs_path: $abs_path" if ($debug); my $isis_file = "$abs_path../t/winisis/BIBL"; -$isis_file = '/data/hidra/THS/THS'; +#$isis_file = '/data/hidra/THS/THS'; +$isis_file = '/data/isis_data/ffkk/'; diag "isis_file: $isis_file" if ($debug); my $normalize_set_pl = "$abs_path/data/normalize.pl"; my $lookup_file = "$abs_path../conf/lookup/isis.pm"; +my ($t1,$t2) = (0,0); + ok(my $lookup = new WebPAC::Lookup( lookup_file => $lookup_file, ), "new Lookup"); @@ -40,7 +44,8 @@ ok(my $isis = new WebPAC::Input( module => 'WebPAC::Input::ISIS', code_page => 'ISO-8859-2', # application encoding - limit => 10, + limit => 100, + no_progress_bar => 1, ), "new Input::ISIS"); ok(my $maxmfn = $isis->open( @@ -61,6 +66,7 @@ db => $db, lookup_regex => $lookup->regex, lookup => $lookup, + no_progress_bar => 1, ), "new Normalize::XML"); ok($n->open( @@ -75,30 +81,43 @@ filters => { foo => sub { shift } }, ), "new Output::TT"); -while (my $row = $isis->fetch) { +diag " lookup => ",Dumper($lookup->lookup_hash) if ($debug); + +foreach my $pos ( 0 ... $isis->size ) { + + my $row = $isis->fetch || next; - diag " row => ",Dumper($row) if ($debug); - set_rec( $row ); + diag " row $pos => ",Dumper($row) if ($debug); + + my $t = time(); ok(my $ds = $n->data_structure($row), "data_structure"); - diag " ds => ",Dumper($ds) if ($debug); + $t1 += time() - $t; + + diag " ds $pos => ",Dumper($ds) if ($debug); + + $t = time(); + my $ds2; # TODO move somewhere { no strict 'subs'; use WebPAC::Normalize::Set; - diag " lookup => ",Dumper($lookup) if ($debug); set_lookup( $lookup->lookup_hash ); + set_rec( $row ); clean_ds(); eval "$norm_pl"; ok(! $@, $@ ? "error: $@" : "no error"); - ok(my $ds2 = get_ds(), "get_ds"); - is_deeply( $ds, $ds2, 'ds same for xml and sets'); - - diag " ds2 => ",Dumper($ds2) if ($debug); + ok($ds2 = get_ds(), "get_ds"); + } + $t2 += time() - $t; + + diag " ds2 $pos => ",Dumper($ds2) if ($debug); + is_deeply( $ds, $ds2, 'ds same for xml and sets'); + ok(my $html = $out->apply( template => 'html.tt', data => $ds, @@ -109,3 +128,5 @@ #diag $html; }; + +diag sprintf("timings: %.2fs vs %.2fs [%1.2f%%]\n", $t1, $t2, ($t1 / $t2) * 100);