From 83a277c9a93493668f4d922cdde4f9d5c0ece7d8 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 27 Mar 2010 21:22:25 +0100 Subject: [PATCH 1/1] mop: Added utilities for calibration of time limits --- mop/Makefile | 1 + mop/calibrate/Makefile | 8 ++++ mop/calibrate/cal-prepare.sh | 13 ++++++ mop/calibrate/cal-try.sh | 84 ++++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 mop/calibrate/Makefile create mode 100755 mop/calibrate/cal-prepare.sh create mode 100755 mop/calibrate/cal-try.sh diff --git a/mop/Makefile b/mop/Makefile index 222a3f1..2418101 100644 --- a/mop/Makefile +++ b/mop/Makefile @@ -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 index 0000000..810dbce --- /dev/null +++ b/mop/calibrate/Makefile @@ -0,0 +1,8 @@ +# Makefile for MO-P contest environment +# (c) 2010 Martin Mares + +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 index 0000000..eeeb3fb --- /dev/null +++ b/mop/calibrate/cal-prepare.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# Time limit calibrator: Gathering of timing data +# (c) 2010 Martin Mares + +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 index 0000000..c1874f1 --- /dev/null +++ b/mop/calibrate/cal-try.sh @@ -0,0 +1,84 @@ +#!/usr/bin/perl +# Time limit calibrator: Simulation +# (c) 2010 Martin Mares + +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 () { + 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 () { + chomp; + my ($test, $pts, $comment) = split /\s+/; + $points{$sol}{$test} = $pts; + } + close PTS; + + open LOG, "cal/$t/$sol.log" or die; + while () { + 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); +} -- 2.39.2