2 # Time limit calibrator: Simulation
3 # (c) 2010 Martin Mares <mj@ucw.cz>
7 use List::Util qw(max);
9 my $t = $ARGV[0] or die;
10 my $thresh = $ARGV[1] || 999;
17 for my $a (<cal/$t/*.points>) {
20 $sol =~ s/\.points$//;
21 my ($want) = ($sol =~ m{(\d+)}) or die "Cannot parse $sol\n";
22 print "$sol (want $want):" if $debug;
28 my ($test, $pts, $comment) = split /\s+/;
29 $points{$sol}{$test} = $pts;
33 open LOG, "cal/$t/$sol.log" or die;
36 my ($test, $time) = m{/(\d+[a-z]*)\.log:.*\(([0-9.]+) } or die "Log parse error: $_";
37 $times{$sol}{$test} = $time;
41 for my $t (sort keys %{$points{$sol}}) {
42 defined $times{$sol}{$t} or $times{$sol}{$t}=0;
43 print " $t:", $points{$sol}{$t}, "/", $times{$sol}{$t} if $debug;
49 print "\n## Threshold=$thresh\n\n";
51 for my $s (sort keys %want) {
58 for my $t (sort keys %{$points{$s}}) {
61 if ($g ne $lastg && $lastg ne '') {
67 if ($times{$s}{$t} <= $thresh) {
68 push @acc, ($points{$s}{$t} ? "+" : 0);
69 $pts{$g} = $points{$s}{$t};
70 $oks{$g}++ if $points{$s}{$t};
71 $maxtime = max($maxtime, $times{$s}{$t});
78 for my $g (keys %groups) {
79 if ($groups{$g} == $oks{$g}) {
83 printf "%-40s %2d/%2d %2.3f %s\n", $s, $sum, $want{$s}, $maxtime, join("", @acc);