Skip to content

Commit 60858fe

Browse files
jimctonycoz
authored andcommitted
provide per-PUT environment
This patch lets user specify ENVAR=value pairs for individual PUTs, thereby altering runtime behavior. For some combination of module and ENVAR, this should result in measurable benchmark differences. This example benchmarks a PERL_MEM_LOG configured perl, 1st PUT with PERL_MEM_LOG disabled, but enabled in the 2nd: $ perl Porting/bench.pl --jobs=2 \ --verbose --debug --tests=/loop::for::pkg_/ \ -- \ perl5.23.9:+bare \ perl5.23.9=+full:PERL_MEM_LOG=3mst,PERLIO=:stdio -MData::Dumper this will run: Command: PERL_HASH_SEED=0 PERLIO=:stdio PERL_MEM_LOG=3mst valgrind --tool=cachegrind --branch-sim=yes --cachegrind-out-file=/dev/null perl5.23.9 -MData::Dumper - 20 2>&1 Note that ':' is now a valid separator between the perl & label, but not between ENVAR=value pairs, where a ',' is required.
1 parent 857716c commit 60858fe

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Porting/bench.pl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,19 +493,23 @@ sub process_puts {
493493
for my $p (reverse @_) {
494494
push @putargs, $p and next if $p =~ /^-/; # not-perl, dont send to qx//
495495

496-
my ($perl, $label) = split /=/, $p, 2;
496+
my ($perl, $label, $env) = split /[=:,]/, $p, 3;
497497
$label //= $perl;
498498
$label = $perl.$label if $label =~ /^\+/;
499499
die "$label cannot be used on 2 different PUTs\n" if $seen{$label}++;
500500

501+
my %env;
502+
if ($env) {
503+
%env = split /[=,]/, $env;
504+
}
501505
my $r = qx($perl -e 'print qq(ok\n)' 2>&1);
502506
if ($r eq "ok\n") {
503-
push @res_puts, [ $perl, $label, reverse @putargs ];
507+
push @res_puts, [ $perl, $label, \%env, reverse @putargs ];
504508
@putargs = ();
505509
warn "Added Perl-Under-Test: [ @{[@{$res_puts[-1]}]} ]\n"
506510
if $OPTS{verbose};
507511
} else {
508-
warn "putargs: @putargs + $p, a not-perl: $r\n"
512+
warn "PUT-args: @putargs + a not-perl: $p $r\n"
509513
if $OPTS{verbose};
510514
push @putargs, $p; # not-perl
511515
}
@@ -725,14 +729,18 @@ sub grind_run {
725729
);
726730

727731
for my $p (@$perls) {
728-
my ($perl, $label, @putargs) = @$p;
732+
my ($perl, $label, $env, @putargs) = @$p;
729733

730734
# Run both the empty loop and the active loop
731735
# $counts->[0] and $counts->[1] times.
732736

733737
for my $i (0,1) {
734738
for my $j (0,1) {
735-
my $cmd = "PERL_HASH_SEED=0 "
739+
my $envstr = '';
740+
if (ref $env) {
741+
$envstr .= "$_=$env->{$_} " for sort keys %$env;
742+
}
743+
my $cmd = "PERL_HASH_SEED=0 $envstr"
736744
. "valgrind --tool=cachegrind --branch-sim=yes "
737745
. "--cachegrind-out-file=/dev/null "
738746
. "$OPTS{grindargs} "

0 commit comments

Comments
 (0)