41
41
# Each test is defined in a file <test>.vgperf, containing one or more of the
42
42
# following lines, in any order:
43
43
# - prog: <prog to run> (compulsory)
44
# - tools: <Valgrind tools> (compulsory)
45
44
# - args: <args for prog> (default: none)
46
45
# - vgopts: <Valgrind options> (default: none)
47
46
# - prereq: <prerequisite command> (default: none)
63
62
options for the user, with defaults in [ ], are:
64
63
-h --help show this message
65
64
--all run all tests under this directory
66
--reps number of repeats for each program [3]
65
--reps=<n> number of repeats for each program [1]
66
--tools=<t1,t2,t3> tools to run [Nulgrind and Memcheck]
67
67
--vg Valgrind(s) to measure (can be specified multiple
68
68
times). The "in-place" build is used.
69
69
[Valgrind in the current directory]
71
Any tools named in --tools must be present in all directories specified
72
with --vg. (This is not checked.)
76
79
my $args; # test prog args
77
80
my $prereq; # prerequisite test to satisfy before running test
78
81
my $cleanup; # cleanup command to run
79
my @tools; # which tools are we measuring the program with
81
# Abbreviations used in output
89
83
# Command line options
90
my $n_reps = 1; # Run each program $n_reps times and choose the best one.
91
my @vgdirs; # Dirs of the various Valgrinds being measured.
84
my $n_reps = 1; # Run each test $n_reps times and choose the best one.
85
my @vgdirs; # Dirs of the various Valgrinds being measured.
86
my @tools = ("none", "memcheck"); # tools being measured
93
88
my $num_tests_done = 0;
94
89
my $num_timings_done = 0;
203
192
} elsif ($line =~ /^\s*prog:\s*(.*)$/) {
204
193
$prog = validate_program(".", $1, 1, 1);
205
} elsif ($line =~ /^\s*tools:\s*(.*)$/) {
206
@tools = validate_tools($1);
207
194
} elsif ($line =~ /^\s*args:\s*(.*)$/) {
209
196
} elsif ($line =~ /^\s*prereq:\s*(.*)$/) {
252
240
die "\n*** Command returned non-zero ($retval)"
253
241
. "\n*** See perf.{cmd,stdout,stderr} to determine what went wrong.\n";
254
242
my $out = `cat perf.stderr`;
255
($out =~ /usertime: ([\d\.]+)s/) or
243
($out =~ /[Uu]ser +([\d\.]+)/) or
256
244
die "\n*** missing usertime in perf.stderr\n";
257
245
$tmin = $1 if ($1 < $tmin);
294
282
printf("%-10s:", $vgdirname);
296
284
# Native execution time
297
printf("%4.1fs", $tNative);
285
printf("%4.2fs", $tNative);
299
287
foreach my $tool (@tools) {
300
(defined $toolnames{$tool}) or
301
die "unknown tool $tool, please add to %toolnames\n";
288
# First two chars of toolname for abbreviation
289
my $tool_abbrev = $tool;
290
$tool_abbrev =~ s/(..).*/$1/;
303
292
# Do the tool run(s). Set both VALGRIND_LIB and VALGRIND_LIB_INNER
304
293
# in case this Valgrind was configured with --enable-inner. And
305
294
# also VALGRINDLIB, which was the old name for the variable, to
306
295
# allow comparison against old Valgrind versions (eg. 2.4.X).
307
printf(" %s:", $toolnames{$tool});
296
printf(" %s:", $tool_abbrev);
308
297
my $vgsetup = "VALGRINDLIB=$vgdir/.in_place "
309
298
. "VALGRIND_LIB=$vgdir/.in_place "
310
299
. "VALGRIND_LIB_INNER=$vgdir/.in_place ";
311
300
my $vgcmd = "$vgdir/coregrind/valgrind "
312
301
. "--command-line-only=yes --tool=$tool -q "
313
. "--memcheck:leak-check=no --addrcheck:leak-check=no "
302
. "--memcheck:leak-check=no "
303
. "--trace-children=yes "
315
305
my $cmd = "$vgsetup $timecmd $vgcmd $prog $args";
316
306
my $tTool = time_prog($cmd, $n_reps);
351
341
my ($dir, $prev_dirs) = @_;
352
342
$dir =~ s/\/$//; # trim a trailing '/'
344
chomp(my $initial_dir = `pwd`); # record where we started
354
346
# Ignore dirs into which we should not recurse.
355
347
if ($dir =~ /^(BitKeeper|CVS|SCCS|docs|doc)$/) { return; }