Changeset 122 for util/title_testharness

Show
Ignore:
Timestamp:
10/23/06 00:25:16 (7 years ago)
Author:
max
Message:

Compare algorithms.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • util/title_testharness

    r121 r122  
    3232        'show_matches'          => \$opt->{show_matches}, 
    3333        'test=s'                => \$opt->{test}, 
     34        'compare=s'             => \$opt->{compare}, 
    3435        'help'                  => \$opt->{help}); 
    3536 
    3637printf "tiele-matching test harness\n"; 
    37 if (($opt->{help}) || (!defined $opt->{test}) && (!defined $opt->{create})) { 
     38if (($opt->{help}) || (!defined $opt->{test}) && (!defined $opt->{create}) && !defined $opt->{compare} ) { 
    3839        print "  usage:\n". 
    3940              "\t$0 --create (title_file) [FILE(s)]\n". 
     
    5152 
    5253@ARGV = ('-') if not @ARGV; 
    53  
     54$opt->{test} = $opt->{compare} if ($opt->{compare}); 
    5455&create_programme_lineup($opt->{create}) if ($opt->{create}); 
    5556&test_algorithms($opt->{test}) if ($opt->{test}); 
     
    201202        } 
    202203 
     204        &test_alg() if ($opt->{compare}); 
     205 
    203206        printf STDERR "\n"; 
    204207        printf STDERR "to see details on matches, use the --show_matches option.\n" unless $opt->{show_matches}; 
     
    215218        my $alg_start = [gettimeofday]; 
    216219 
     220        my ($al1, $al2); 
     221        if ($opt->{compare} and $opt->{compare} =~ /(.*),(.*)/) { 
     222            if ($algorithms{$1} and $algorithms{$2}) { 
     223                ($al1, $al2) = ($1, $2); 
     224                print "Comparing $al1 to $al2.\n"; 
     225            } 
     226        } 
     227             
    217228        foreach my $timeslot (0..$#{$prog_lineup}) { 
    218229                foreach my $source (0..$datafile_num) { 
     
    232243                                foreach my $prog1 (@c1) { 
    233244                                        foreach my $prog2 (@c2) { 
    234                                                 if ($algorithms{$alg}->($prog1,$prog2)) { 
     245 
     246                                                # No point comparing the same string, is there? 
     247                                                next if ($prog1 eq $prog2); 
     248 
     249                                                if ($al1 and $al2) { 
     250                                                    my $m1 = $algorithms{$al1}->($prog1,$prog2); 
     251                                                    my $m2 = $algorithms{$al2}->($prog1,$prog2); 
     252                                                    if ($m1 != $m2) { 
     253                                                        print "\"$prog1\" vs \"$prog2\": $al1 says " . 
     254                                                              ($m1 ? "MATCH" : "NON-MATCH") . 
     255                                                              " and $al2 says " . 
     256                                                              ($m2 ? "MATCH" : "NON-MATCH") .  
     257                                                              ".\n"; 
     258                                                    } 
     259                                                } 
     260                                                else { 
     261                                                    if ($algorithms{$alg}->($prog1,$prog2)) { 
    235262                                                        printf "algorithm $alg said '$prog1' and '$prog2' DO match\n" if ($opt->{show_matches}); 
    236263                                                        $matches++; 
    237                                                 } else { 
     264                                                    } else { 
    238265                                                        printf "algorithm $alg said '$prog1' and '$prog2' don't match\n" if ($opt->{show_non_matches}); 
    239266                                                        $non_matches++; 
     267                                                    } 
    240268                                                } 
    241269                                        }