~bkerensa/ubuntu/raring/valgrind/merge-from-deb

« back to all changes in this revision

Viewing changes to perf/vg_perf.in

  • Committer: Benjamin Kerensa
  • Date: 2012-11-21 23:57:58 UTC
  • mfrom: (1.1.16)
  • Revision ID: bkerensa@ubuntu.com-20121121235758-bd1rv5uc5vzov2p6
Merge from debian unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
#
44
44
# The prerequisite command, if present, must return 0 otherwise the test is
45
45
# skipped.
 
46
# Sometimes it is useful to run all the tests at a high sanity check
 
47
# level or with arbitrary other flags.  To make this simple, extra 
 
48
# options, applied to all tests run, are read from $EXTRA_REGTEST_OPTS,
 
49
# and handed to valgrind prior to any other flags specified by the 
 
50
# .vgperf file. Note: the env var is the same as vg_regtest.
46
51
#----------------------------------------------------------------------------
47
52
 
48
53
use warnings;
58
63
    -h --help             show this message
59
64
    --reps=<n>            number of repeats for each program [1]
60
65
    --tools=<t1,t2,t3>    tools to run [Nulgrind and Memcheck]
61
 
    --vg                  Valgrind(s) to measure (can be specified multiple
62
 
                            times).  The "in-place" build is used.
63
 
                            [Valgrind in the current directory]
 
66
    --vg                  Valgrind(s) to measure  [Valgrind in the current directory]
 
67
                          (can be specified multiple times).
 
68
                          The "in-place" build is used.
 
69
 
 
70
    --outer-valgrind: run these Valgrind(s) under the given outer valgrind.
 
71
      These Valgrind(s) must be configured with --enable-inner.
 
72
    --outer-tool: tool to use by the outer valgrind (default cachegrind).
 
73
    --outer-args: use this as outer tool args.
64
74
 
65
75
  Any tools named in --tools must be present in all directories specified
66
76
  with --vg.  (This is not checked.)
 
77
  Use EXTRA_REGTEST_OPTS to supply extra args for all tests
67
78
END
68
79
;
69
80
 
79
90
my @vgdirs;             # Dirs of the various Valgrinds being measured.
80
91
my @tools = ("none", "memcheck");   # tools being measured
81
92
 
 
93
# Outer valgrind to use, and args to use for it.
 
94
# If this is set, --valgrind should be set to the installed inner valgrind,
 
95
# and --valgrind-lib will be ignore
 
96
my $outer_valgrind;
 
97
my $outer_tool = "cachegrind";
 
98
my $outer_args;
 
99
 
 
100
 
82
101
my $num_tests_done   = 0;
83
102
my $num_timings_done = 0;
84
103
 
119
138
{
120
139
    my ($vgdir) = @_;
121
140
    if ($vgdir !~ /^\//) { $vgdir = "$tests_dir/$vgdir"; }
122
 
    validate_program($vgdir, "./coregrind/valgrind", 1, 1);
123
141
    push(@vgdirs, $vgdir);
124
142
}
125
143
 
137
155
                add_vgdir($1);
138
156
            } elsif ($arg =~ /^--tools=(.+)$/) {
139
157
                @tools = split(/,/, $1);
 
158
            } elsif ($arg =~ /^--outer-valgrind=(.*)$/) {
 
159
                $outer_valgrind = $1;
 
160
            } elsif ($arg =~ /^--outer-tool=(.*)$/) {
 
161
                $outer_tool = $1;
 
162
            } elsif ($arg =~ /^--outer-args=(.*)$/) {
 
163
                $outer_args = $1;
140
164
            } else {
141
165
                die $usage;
142
166
            }
256
280
    my $cmd     = "$timecmd $prog $args";
257
281
    my $tNative = time_prog($cmd, $n_reps);
258
282
 
 
283
    if (defined $outer_valgrind) {
 
284
        $outer_valgrind = validate_program($tests_dir, $outer_valgrind, 1, 1);
 
285
        foreach my $vgdir (@vgdirs) {
 
286
            validate_program($vgdir, "./coregrind/valgrind", 1, 1);
 
287
        }
 
288
    } else {
 
289
        foreach my $vgdir (@vgdirs) {
 
290
            validate_program($vgdir, "./coregrind/valgrind", 1, 1);
 
291
        }
 
292
    }
 
293
 
 
294
    # Pull any extra options (for example, --sanity-level=4)
 
295
    # from $EXTRA_REGTEST_OPTS.
 
296
    my $maybe_extraopts = $ENV{"EXTRA_REGTEST_OPTS"};
 
297
    my $extraopts = $maybe_extraopts ?  $maybe_extraopts  : "";
 
298
 
259
299
    foreach my $vgdir (@vgdirs) {
260
300
        # Benchmark name
261
301
        printf("%-8s ", $name);
272
312
            # First two chars of toolname for abbreviation
273
313
            my $tool_abbrev = $tool;
274
314
            $tool_abbrev =~ s/(..).*/$1/;
275
 
 
276
 
            # Do the tool run(s).  Set both VALGRIND_LIB and VALGRIND_LIB_INNER
277
 
            # in case this Valgrind was configured with --enable-inner.  And
278
 
            # also VALGRINDLIB, which was the old name for the variable, to
279
 
            # allow comparison against old Valgrind versions (eg. 2.4.X).
280
315
            printf("  %s:", $tool_abbrev);
281
 
            my $vgsetup = "VALGRINDLIB=$vgdir/.in_place "
282
 
                        . "VALGRIND_LIB=$vgdir/.in_place "
283
 
                        . "VALGRIND_LIB_INNER=$vgdir/.in_place ";
 
316
            my $run_outer_args = "";
 
317
            if (not defined $outer_args) {
 
318
                $run_outer_args = 
 
319
                      " -v --command-line-only=yes"
 
320
                    . " --run-libc-freeres=no --sim-hints=enable-outer"
 
321
                    . " --smc-check=all-non-file"
 
322
                    . " --vgdb=no --trace-children=yes --read-var-info=no"
 
323
                    . " --suppressions=../tests/outer_inner.supp"
 
324
                    . " --memcheck:leak-check=full --memcheck:show-reachable=no"
 
325
                    . " --cachegrind:cache-sim=yes --cachegrind:branch-sim=yes"
 
326
                    . " --cachegrind:cachegrind-out-file=cachegrind.out.$vgdirname.$tool_abbrev.$name.%p"
 
327
                    . " --callgrind:cache-sim=yes --callgrind:branch-sim=yes"
 
328
                    . " --callgrind:dump-instr=yes --callgrind:collect-jumps=yes"
 
329
                    . " --callgrind:callgrind-out-file=callgrind.out.$vgdirname.$tool_abbrev.$name.%p"
 
330
                    . " ";
 
331
            } else {
 
332
                $run_outer_args = $outer_args;
 
333
            }
 
334
 
 
335
            my $vgsetup = "";
284
336
            my $vgcmd   = "$vgdir/coregrind/valgrind "
285
 
                        . "--command-line-only=yes --tool=$tool -q "
 
337
                        . "--command-line-only=yes --tool=$tool  $extraopts -q "
286
338
                        . "--memcheck:leak-check=no "
287
339
                        . "--trace-children=yes "
288
340
                        . "$vgopts ";
 
341
            # Do the tool run(s).
 
342
            if (defined $outer_valgrind ) {
 
343
                # in an outer-inner setup, only set VALGRIND_LIB_INNER
 
344
                $vgsetup = "VALGRIND_LIB_INNER=$vgdir/.in_place ";
 
345
                $vgcmd   = "$outer_valgrind "
 
346
                         . "--tool=" . $outer_tool . " "
 
347
                         . "$run_outer_args "
 
348
                         . "--log-file=" . "$outer_tool.outer.log.$vgdirname.$tool_abbrev.$name.%p "
 
349
                         . $vgcmd;
 
350
            } else {
 
351
                # Set both VALGRIND_LIB and VALGRIND_LIB_INNER
 
352
                # in case this Valgrind was configured with --enable-inner.  And
 
353
                # also VALGRINDLIB, which was the old name for the variable, to
 
354
                # allow comparison against old Valgrind versions (eg. 2.4.X).
 
355
                $vgsetup = "VALGRINDLIB=$vgdir/.in_place "
 
356
                         . "VALGRIND_LIB=$vgdir/.in_place "
 
357
                         . "VALGRIND_LIB_INNER=$vgdir/.in_place ";
 
358
            }
289
359
            my $cmd     = "$vgsetup $timecmd $vgcmd $prog $args";
290
360
            my $tTool   = time_prog($cmd, $n_reps);
291
361
            printf("%4.1fs (%4.1fx,", $tTool, $tTool/$tNative);
368
438
#----------------------------------------------------------------------------
369
439
# main()
370
440
#----------------------------------------------------------------------------
 
441
sub warn_about_EXTRA_REGTEST_OPTS()
 
442
{
 
443
    print "WARNING: \$EXTRA_REGTEST_OPTS is set.  You probably don't want\n";
 
444
    print "to run the perf tests with it set, unless you are doing some\n";
 
445
    print "strange experiment, and/or you really know what you are doing.\n";
 
446
    print "\n";
 
447
}
371
448
 
372
449
# nuke VALGRIND_OPTS
373
450
$ENV{"VALGRIND_OPTS"} = "";
374
451
 
 
452
if ($ENV{"EXTRA_REGTEST_OPTS"}) {
 
453
    print "\n";
 
454
    warn_about_EXTRA_REGTEST_OPTS();
 
455
}
 
456
 
375
457
my @fs = process_command_line();
376
458
foreach my $f (@fs) {
377
459
    if (-d $f) {
394
476
}
395
477
summarise_results();
396
478
 
 
479
if ($ENV{"EXTRA_REGTEST_OPTS"}) {
 
480
    warn_about_EXTRA_REGTEST_OPTS();
 
481
}
 
482
 
397
483
##--------------------------------------------------------------------##
398
484
##--- end                                                          ---##
399
485
##--------------------------------------------------------------------##