~ubuntu-branches/debian/sid/valgrind/sid

« back to all changes in this revision

Viewing changes to perf/vg_perf

  • Committer: Bazaar Package Importer
  • Author(s): Andrés Roldán
  • Date: 2008-06-13 02:31:40 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080613023140-rezbg9gtvybimy2q
Tags: 1:3.3.1-2
* debian/rules:
  - Forgot to copy debian-libc6-dbg.supp to /usr/lib/valgrind. 
    (Closes: #486021)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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]
 
70
 
 
71
  Any tools named in --tools must be present in all directories specified
 
72
  with --vg.  (This is not checked.)
70
73
END
71
74
;
72
75
 
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
80
 
 
81
 
# Abbreviations used in output
82
 
my %toolnames = ( 
83
 
    none        => "nl",
84
 
    memcheck    => "mc",
85
 
    cachegrind  => "cg",
86
 
    massif      => "ms"
87
 
);
88
82
 
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
92
87
 
93
88
my $num_tests_done   = 0;
94
89
my $num_timings_done = 0;
126
121
    return $prog;
127
122
}
128
123
 
129
 
sub validate_tools($)
130
 
{
131
 
    # XXX: should check they exist!
132
 
    my ($toolnames) = @_;
133
 
    my @t = split(/\s+/, $toolnames);
134
 
    return @t;
135
 
}
136
 
 
137
124
sub add_vgdir($)
138
125
{
139
126
    my ($vgdir) = @_;
157
144
            } elsif ($arg =~ /^--vg=(.+)$/) {
158
145
                # Make dir absolute if not already
159
146
                add_vgdir($1);
 
147
            } elsif ($arg =~ /^--tools=(.+)$/) {
 
148
                @tools = split(/,/, $1);
160
149
            } else {
161
150
                die $usage;
162
151
            }
202
191
            $vgopts = $1;
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*(.*)$/) {
208
195
            $args = $1;
209
196
        } elsif ($line =~ /^\s*prereq:\s*(.*)$/) {
240
227
    }
241
228
}
242
229
 
243
 
# Run program N times, return the best user time.
 
230
# Run program N times, return the best user time.  Use the POSIX
 
231
# -p flag on /usr/bin/time so as to get something parseable on AIX.
244
232
sub time_prog($$)
245
233
{
246
234
    my ($cmd, $n) = @_;
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);
258
246
    }
277
265
        }
278
266
    }
279
267
 
280
 
    my $timecmd = "/usr/bin/time -f 'usertime: %Us'";
 
268
    my $timecmd = "/usr/bin/time -p";
281
269
 
282
270
    # Do the native run(s).
283
271
    printf("-- $name --\n") if (@vgdirs > 1);
294
282
        printf("%-10s:", $vgdirname);
295
283
        
296
284
        # Native execution time
297
 
        printf("%4.1fs", $tNative);
 
285
        printf("%4.2fs", $tNative);
298
286
 
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/;
302
291
 
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 "
314
304
                        . "$vgopts ";
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 '/'
353
343
 
 
344
    chomp(my $initial_dir = `pwd`);     # record where we started
 
345
 
354
346
    # Ignore dirs into which we should not recurse.
355
347
    if ($dir =~ /^(BitKeeper|CVS|SCCS|docs|doc)$/) { return; }
356
348
 
377
369
        print "-- Finished tests in $full_dir $dashes\n";
378
370
    }
379
371
 
380
 
    chdir("..");
 
372
    chdir("$initial_dir");
381
373
}
382
374
 
383
375
#----------------------------------------------------------------------------