From: Tara L Andrews Date: Thu, 17 Nov 2011 10:32:50 +0000 (+0100) Subject: add benchmarking; turn on all files X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e4386ba9f907d6dff06bb6f53ec4a3bf810ee2ba;p=scpubgit%2Fstemmatology.git add benchmarking; turn on all files --- diff --git a/TreeOfTexts/lib/TreeOfTexts/Model/Analysis.pm b/TreeOfTexts/lib/TreeOfTexts/Model/Analysis.pm index 9c64b23..08b8e0d 100644 --- a/TreeOfTexts/lib/TreeOfTexts/Model/Analysis.pm +++ b/TreeOfTexts/lib/TreeOfTexts/Model/Analysis.pm @@ -8,14 +8,14 @@ use base 'Catalyst::Model::Adaptor'; __PACKAGE__->config( class => 'Text::Tradition::Analysis', args => { 'traditions' => [ -# { 'file' => TreeOfTexts->path_to( 't', 'data', 'florilegium.xml' ), -# 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_a.dot' ) }, + { 'file' => TreeOfTexts->path_to( 't', 'data', 'florilegium.xml' ), + 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_a.dot' ) }, { 'file' => TreeOfTexts->path_to( 't', 'data', 'besoin.xml' ), 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_b.dot' ) }, -# { 'file' => TreeOfTexts->path_to( 't', 'data', 'heinrichi.xml' ), -# 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_h.dot' ) }, -# { 'file' => TreeOfTexts->path_to( 't', 'data', 'parzival.xml' ), -# 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_p.dot' ) }, + { 'file' => TreeOfTexts->path_to( 't', 'data', 'heinrichi.xml' ), + 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_h.dot' ) }, + { 'file' => TreeOfTexts->path_to( 't', 'data', 'parzival.xml' ), + 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_p.dot' ) }, { 'file' => TreeOfTexts->path_to( 't', 'data', 's158.xml' ), 'stemmadot' => TreeOfTexts->path_to( 't', 'data', 'stemma_s.dot' ) }, ] }, diff --git a/lib/Text/Tradition/Analysis.pm b/lib/Text/Tradition/Analysis.pm index 5d4e335..ea01366 100644 --- a/lib/Text/Tradition/Analysis.pm +++ b/lib/Text/Tradition/Analysis.pm @@ -2,6 +2,7 @@ package Text::Tradition::Analysis; use strict; use warnings; +use Benchmark; use Exporter 'import'; use Text::Tradition; use Text::Tradition::Stemma; @@ -65,11 +66,13 @@ sub run_analysis { # We will return a data structure, an array for each row that looks like: # { id = X, genealogical = Y, readings = [ text = X, group = Y], empty = N } + my $rank = 0; + my $t0 = Benchmark->new(); foreach my $i ( 0 .. $#$all_wits_table ) { # For each column in the table, group the readings by witness. my $rdg_wits = {}; my $col_rdgs = shift @$all_wits_table; - my $rank; + # my $rank; my $lacunose = [ @not_collated ]; foreach my $j ( 0 .. $#{$col_rdgs} ) { my $rdg = $col_rdgs->[$j]; @@ -81,7 +84,7 @@ sub run_analysis { } else { $rdg_text = $rdg->text; # Get the rank from any real reading; they should be identical. - $rank = $rdg->rank; + # $rank = $rdg->rank; } } if( defined $rdg_text ) { @@ -98,6 +101,7 @@ sub run_analysis { $total++ unless scalar keys %$rdg_wits == 1; my( $groups, $readings ) = useful_variant( $rdg_wits ); next unless $groups && $readings; + $rank++; # Keep track of our widest row $html_columns = scalar @$groups if scalar @$groups > $html_columns; @@ -132,6 +136,9 @@ sub run_analysis { # Record that we used this variant in an analysis push( @$variants, $variant_row ); } + my $t1 = Benchmark->new(); + print STDERR "Analysis of graph for " . $tradition->name . " took " + . timestr( timediff( $t1, $t0 ) ) . "seconds\n"; # Go through our variant rows, after we have seen all of them once, # and add the number of empty columns needed by each.