forked from regehr/str2long_contest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
evaluate.pl
executable file
·153 lines (138 loc) · 3.16 KB
/
evaluate.pl
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/perl -w
use strict;
my $CFLAGS = "-w -DNDEBUG -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables";
my %comps = (
"gcc-4.4" => "gcc-4.4",
"gcc-4.5" => "gcc-4.5",
"gcc-4.6" => "gcc-4.6",
"gcc-4.7" => "gcc-4.7",
"/home/regehr/z/compiler-install/gcc-r196703-install/bin/gcc" => "gcc-trunk",
"/home/regehr/z/clang+llvm-3.0-x86_64-linux-Ubuntu-11_10/bin/clang" => "clang-3.0",
"/home/regehr/z/clang+llvm-3.1-x86_64-linux-ubuntu_12.04/bin/clang" => "clang-3.1",
"/home/regehr/z/clang+llvm-3.2-x86_64-linux-ubuntu-12.04/bin/clang" => "clang-3.2",
"/home/regehr/z/compiler-install/llvm-r177225-install/bin/clang" => "clang-trunk",
"icc" => "icc-12.0.5",
"/opt/intel/bin/icc" => "icc-13.1.0",
);
my @opts = (
"-O0",
"-O1",
"-O2",
"-Os",
"-O3",
);
my @progs = (
"pascal",
"bernd_2",
"francois_2",
"yolanpa",
"patrick",
"daniel_2",
"phil",
"mikael_2",
"ryan",
"matthew_3",
"stefan",
"david_2",
"mats",
"peter",
"thomas",
"mattias",
"matthewf_2",
"kevin",
"chucky_2",
"andrew",
"tordek_2",
"jeffrey",
"yang_2",
"olivier",
"davidl",
"davidl_2",
"bastian",
"ethan_2",
"renaud",
"till",
"greg",
"ben",
"davide",
"davide_3",
"sidney",
"libc",
);
if (1) {
my @outfs = ();
foreach my $comp (keys %comps) {
system "rm -f *.o";
foreach my $opt (@opts) {
my $ofiles = "";
foreach my $prog (@progs) {
my $ofile = "${prog}.o";
$ofiles .= "$ofile ";
my $cfile = "${prog}.c";
my $cmd = "$comp $CFLAGS $opt -c $cfile";
system $cmd;
}
system "$comp $CFLAGS $opt str2long_test.c $ofiles -o str2long_test -lm -lrt";
my $outf = "speed-$comps{$comp}$opt.txt";
print "$outf\n";
push @outfs, $outf;
system "./str2long_test > $outf";
}
}
my %fastest;
my %fastest_comp;
foreach my $outf (@outfs) {
open INF, "<$outf" or die;
while (my $line = <INF>) {
if ($line =~ /([0-9\.]+) (.*)/) {
my $t = $1;
my $who = $2;
if (!defined($fastest{$who}) ||
$t < $fastest{$who}) {
$fastest{$who} = $t;
$fastest_comp{$who} = $outf;
}
}
}
close INF;
}
open OF, "| sort -n >speed.txt" or die;
foreach my $prog (@progs) {
print OF "$fastest{$prog} $fastest_comp{$prog} $prog\n";
}
close OF;
}
if (1) {
system "rm -f *.o";
open OF, "| sort -n >size.txt" or die;
foreach my $prog (@progs) {
my $smallest = 999999;
my $small_opt;
my $small_comp;
my $ofile = "${prog}.o";
my $cfile = "${prog}.c";
foreach my $comp (keys %comps) {
foreach my $opt (@opts) {
my $cmd = "$comp $CFLAGS $opt -c $cfile";
system "rm -f $ofile";
system $cmd;
open INF, "size -A $ofile |" or die;
my $found = 0;
while (my $line = <INF>) {
if ($line =~ /\.text\s+([0-9]+)\s/) {
my $size = $1;
$found = 1;
if ($size < $smallest) {
$smallest = $size;
$small_opt = $opt;
$small_comp = $comp;
}
}
}
die unless ($found);
}
}
print OF "$smallest $comps{$small_comp} $small_opt $prog\n";
}
close OF;
}