Skip to content

Commit

Permalink
Merge pull request #16812 from edsantiago/benchmarks_separate_sd
Browse files Browse the repository at this point in the history
parse-localbenchmarks: separate standard deviation
  • Loading branch information
openshift-merge-robot authored Dec 12, 2022
2 parents 9ef2d9d + 0874149 commit 567486c
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions hack/parse-localbenchmarks
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,7 @@ while (my $line = <STDIN>) {

# e.g., 'Fastest Time: 0.265s'
elsif ($line =~ /^(\S.*?\S):\s+(.*)/) {
my $benchmark = "$type $1";
$results{$testname}{$benchmark} = $2;

# Keep an ordered list of benchmark names (as in, the order we
# encounter them)
push @benchmarks, $benchmark
unless grep { $_ eq $benchmark } @benchmarks;
log_result($testname, $type, $1, $2);
}

else {
Expand All @@ -102,3 +96,38 @@ for my $t (sort keys %results) {
}
print "\n";
}

exit 0;

################
# log_result # Preserve one record
################
sub log_result {
my $testname = shift; # in: test name (eg "podman foo")
my $type = shift; # in: CPU or MEM
my $name = shift; # in: benchmark name (eg "Fastest")
my $result = shift; # in: benchmark value

my $benchmark = "$type $name";
$results{$testname}{$benchmark} = $result;

# Keep an ordered list of benchmark names (as in, the order we
# encounter them)
push @benchmarks, $benchmark
unless grep { $_ eq $benchmark } @benchmarks;

# Special case: "Average X" may be of the form "xxx ± yyy". Move the
# standard deviation to its own column.
if ($name =~ /Average/) {
if ($results{$testname}{$benchmark} =~ s/^(\S+)\s+.*\s+(\S+)$/$1/) {
my ($average, $sd) = ($1, $2);
log_result($testname, $type, 'StdDev', $sd);

# Strip off units, so we can determine it as a percentage
$average =~ s/[a-z]+$//i;
$sd =~ s/[a-z]+$//i;
my $pct = sprintf("%.1f%%", $sd * 100.0 / $average);
log_result($testname, $type, 'StdDev (Percent)', $pct);
}
}
}

0 comments on commit 567486c

Please sign in to comment.