--- trunk/t/6-unit.t 2006/05/13 13:39:09 479 +++ trunk/t/6-unit.t 2006/06/26 16:39:51 536 @@ -2,12 +2,13 @@ use strict; -use Test::More tests => 66; +use Test::More tests => 24; 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; @@ -16,8 +17,8 @@ use_ok( 'WebPAC::Lookup' ); use_ok( 'WebPAC::Input' ); use_ok( 'WebPAC::Store' ); -use_ok( 'WebPAC::Normalize::XML' ); -use_ok( 'WebPAC::Normalize::Set' ); +use_ok( 'WebPAC::Lookup::Normalize' ); +use_ok( 'WebPAC::Normalize' ); use_ok( 'WebPAC::Output::TT' ); } @@ -27,7 +28,7 @@ my $isis_file = "$abs_path../t/winisis/BIBL"; #$isis_file = '/data/hidra/THS/THS'; -$isis_file = '/data/isis_data/ffkk/'; +#$isis_file = '/data/isis_data/ffkk/'; diag "isis_file: $isis_file" if ($debug); @@ -41,7 +42,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( @@ -57,18 +59,6 @@ database => '.', ), "new Store"); -ok(my $n = new WebPAC::Normalize::XML( -# filter => { 'foo' => sub { shift } }, - db => $db, - lookup_regex => $lookup->regex, - lookup => $lookup, -), "new Normalize::XML"); - -ok($n->open( - tag => 'isis', - xml_file => "$abs_path/data/normalize.xml", -), "Normalize::XML->open"); - ok(my $norm_pl = read_file( $normalize_set_pl ), "set definitions: $normalize_set_pl" ); ok(my $out = new WebPAC::Output::TT( @@ -76,29 +66,25 @@ filters => { foo => sub { shift } }, ), "new Output::TT"); -while (my $row = $isis->fetch) { +diag " lookup => ",Dumper($lookup->lookup_hash) if ($debug); - diag " row => ",Dumper($row) if ($debug); - set_rec( $row ); +my $t_norm = 0; - ok(my $ds = $n->data_structure($row), "data_structure"); +foreach my $pos ( 0 ... $isis->size ) { - diag " ds => ",Dumper($ds) if ($debug); + my $row = $isis->fetch || next; - # TODO move somewhere - { - no strict 'subs'; - use WebPAC::Normalize::Set; - diag " lookup => ",Dumper($lookup->lookup_hash) if ($debug); - set_lookup( $lookup->lookup_hash ); - 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 " row $pos => ",Dumper($row) if ($debug); - diag " ds2 => ",Dumper($ds2) if ($debug); - } + my $t = time(); + ok( my $ds = WebPAC::Normalize::data_structure( + lookup => $lookup->lookup_hash, + row => $row, + rules => $norm_pl, + ), "Set data_structure"); + $t_norm += time() - $t; + + diag " ds $pos => ",Dumper($ds) if ($debug); ok(my $html = $out->apply( template => 'html.tt', @@ -110,3 +96,5 @@ #diag $html; }; + +diag sprintf("timings: %.2fs\n", $t_norm);