]> mj.ucw.cz Git - moe.git/commitdiff
mop: Added utilities for calibration of time limits
authorMartin Mares <mj@ucw.cz>
Sat, 27 Mar 2010 20:22:25 +0000 (21:22 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 27 Mar 2010 20:22:25 +0000 (21:22 +0100)
mop/Makefile
mop/calibrate/Makefile [new file with mode: 0644]
mop/calibrate/cal-prepare.sh [new file with mode: 0755]
mop/calibrate/cal-try.sh [new file with mode: 0755]

index 222a3f1e7508ab63019a544c669a3efe19c2164a..24181014fdc8fb5aebf6909c63f67be44df1b4a5 100644 (file)
@@ -7,6 +7,7 @@ include $(s)/mop/admin/Makefile
 include $(s)/mop/eval/Makefile
 include $(s)/mop/public/Makefile
 include $(s)/mop/score/Makefile
+include $(s)/mop/calibrate/Makefile
 
 CONFIGS+=mop userlist
 run/cf/mop: $(o)/mop/mop.cf
diff --git a/mop/calibrate/Makefile b/mop/calibrate/Makefile
new file mode 100644 (file)
index 0000000..810dbce
--- /dev/null
@@ -0,0 +1,8 @@
+# Makefile for MO-P contest environment
+# (c) 2010 Martin Mares <mj@ucw.cz>
+
+DIRS+=mop/calibrate
+PROGS+=$(addprefix $(o)/mop/calibrate/,cal-prepare cal-try)
+
+$(o)/mop/calibrate/cal-prepare: $(s)/mop/calibrate/cal-prepare.sh
+$(o)/mop/calibrate/cal-try: $(s)/mop/calibrate/cal-try.sh
diff --git a/mop/calibrate/cal-prepare.sh b/mop/calibrate/cal-prepare.sh
new file mode 100755 (executable)
index 0000000..eeeb3fb
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+# Time limit calibrator: Gathering of timing data
+# (c) 2010 Martin Mares <mj@ucw.cz>
+
+set -e
+[ -n "$1" ]
+t="$1"
+mkdir -p cal/$t
+for a in `cd solutions/authors/$t && echo * | sed 's/\.[^ ]*//g'` ; do
+       bin/ev authors $t $a
+       cp testing/authors/$t/points cal/$t/$a.points
+       grep syscalls testing/authors/$t/*.log >cal/$t/$a.log
+done
diff --git a/mop/calibrate/cal-try.sh b/mop/calibrate/cal-try.sh
new file mode 100755 (executable)
index 0000000..c1874f1
--- /dev/null
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+# Time limit calibrator: Simulation
+# (c) 2010 Martin Mares <mj@ucw.cz>
+
+use strict;
+use warnings;
+use List::Util qw(max);
+
+my $t = $ARGV[0] or die;
+my $thresh = $ARGV[1] || 999;
+my $debug = 0;
+
+my %want = ();
+my %points = ();
+my %times = ();
+
+for my $a (<cal/$t/*.points>) {
+       my $sol = $a;
+       $sol =~ s/^.*\///;
+       $sol =~ s/\.points$//;
+       my ($want) = ($sol =~ m{(\d+)}) or die "Cannot parse $sol\n";
+       print "$sol (want $want):" if $debug;
+       $want{$sol} = $want;
+
+       open PTS, $a or die;
+       while (<PTS>) {
+               chomp;
+               my ($test, $pts, $comment) = split /\s+/;
+               $points{$sol}{$test} = $pts;
+       }
+       close PTS;
+
+       open LOG, "cal/$t/$sol.log" or die;
+       while (<LOG>) {
+               chomp;
+               my ($test, $time) = m{/(\d+[a-z]*)\.log:.*\(([0-9.]+) } or die "Log parse error: $_";
+               $times{$sol}{$test} = $time;
+       }
+       close LOG;
+
+       for my $t (sort keys %{$points{$sol}}) {
+               defined $times{$sol}{$t} or $times{$sol}{$t}=0;
+               print " $t:", $points{$sol}{$t}, "/", $times{$sol}{$t} if $debug;
+       }
+
+       print "\n" if $debug;
+}
+
+print "\n## Threshold=$thresh\n\n";
+
+for my $s (sort keys %want) {
+       my %groups = ();
+       my %oks = ();
+       my %pts = ();
+       my $maxtime = 0;
+       my @acc;
+       my $lastg = '';
+       for my $t (sort keys %{$points{$s}}) {
+               my $g = $t;
+               $g =~ s{\D+}{};
+               if ($g ne $lastg && $lastg ne '') {
+                       push @acc, "|";
+               }
+               $lastg = $g;
+               $groups{$g}++;
+               $oks{$g} += 0;
+               if ($times{$s}{$t} <= $thresh) {
+                       push @acc, ($points{$s}{$t} ? "+" : 0);
+                       $pts{$g} = $points{$s}{$t};
+                       $oks{$g}++ if $points{$s}{$t};
+                       $maxtime = max($maxtime, $times{$s}{$t});
+               } else {
+                       push @acc, "T";
+               }
+       }
+
+       my $sum = 0;
+       for my $g (keys %groups) {
+               if ($groups{$g} == $oks{$g}) {
+                       $sum += $pts{$g};
+               }
+       }
+       printf "%-40s %2d/%2d  %2.3f  %s\n", $s, $sum, $want{$s}, $maxtime, join("", @acc);
+}