-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJudge
executable file
·81 lines (70 loc) · 1.65 KB
/
Judge
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/perl
#
##
## PerfLab judging script from 2013
##
## Usage:
##
## Judge [-p program] [-i image] [-v] [-n #]
##
## This will run the program N times using the image specified.
## Reasonable defaults are provide.
##
#
use Getopt::Long;
$image = "blocks-small.bmp";
$program = "./filter";
$samples = 6;
$verbose = 0;
$result = GetOptions("program|p=s" => \$program,
"image|i=s" => \$image,
"n=i" => \$samples,
"v" => \$verbose
);
if ( ! ($program =~ "\\..*" )) {
$program = "./$program";
}
-x $program || die "Unable to find executable program $program\n";
-f $image || die "Unable to find image $image\n";
if ( $samples < 4 ) {
printf "Warning - you won't get good results with -n $samples\n";
}
@FILTERS = ("gauss","raised","hline","emboss","edge","sharpen","motionblur");
@scores = ();
for my $filter ( @FILTERS ){
if ( $verbose ) {
print "filter is $filter\n";
}
$cmd = "$program $filter.filter";
for (my $i = 0; $i < $samples; $i++) {
$cmd = "$cmd $image";
}
if ( $verbose ) {
printf "Run $cmd\n";
}
open(OUTPUT, "$cmd 2>&1 |") || die "Unable to run $cmd\n";
printf "$filter: ";
while (<OUTPUT>) {
if (/or ([0-9\.]+) cycles/) {
print $1, "..";
push(@scores, int($1));
}
}
printf "\n";
close(OUTPUT);
}
@scores = sort { int($a) <=> int($b) } @scores;
#print "CPEs are @scores \n";
$median = int( ($#scores + 1) / 2 );
$cpe = $scores[$median];
print "median CPE is ", $cpe, "\n";
if ($cpe > 3000) {
$score = 0;
} else {
$score = log($cpe) * -17 + 173;
if ($score > 110 ) {
$score = 110;
}
}
$score = int($score);
print "Resulting score is $score\n";