) {
chomp;
my @cap;
if (@cap = /$re_row/o) {
push(@{$data[$system]->[$dataset]}, \@cap);
} elsif (/test complete/ || /^\s*$/) {
next;
} else {
print STDERR "Hmm, $file: '$_'\n";
}
}
close(F);
++$dataset;
}
}
my $set_a = longest_common_prefix(@{$filenames[0]});
my $set_b = longest_common_prefix(@{$filenames[1]});
print <<"_end_";
Iozone: $set_a vs $set_b
_end_
print "$header\n";
print_table();
exit(0);
# Map ratio between the two values into an RGB value. This is done by
# first calculating the colour in HSV. H (hue) goes from red (0
# degrees) to green (135 degrees). Yellow is in the middle.
# If the ratio is bigger than $limit, adjust V (value or brightness)
# as well. The brightness is reduced by a third of the log10 of the
# ratio adjusted by $limit. For $limit == 2, this means brightness is
# halved when the factor between the two values is 63. It becomes
# black for a factor of 2000, but blacking out such presumed anomalies
# is probably a feature, not a bug.
sub danger_colour {
my ($val_a, $val_b) = @_;
my $limit = 2;
my $ratio = $val_b / $val_a;
if ($ratio < 1) {
$ratio = -1 / $ratio;
}
my $brightness =
abs($ratio) > $limit
? 1-log(abs($ratio) / $limit) / log(10) / 3
: 1.0;
$ratio = max(min($ratio, $limit), -$limit);
my $hue = 135/2 + ($ratio - $ratio/abs($ratio)) * 135/2/$limit;
return sprintf("#%02x%02x%02x", hsv_to_rgb($hue/360, 1.0, $brightness));
}
sub slurp_header {
my ($fh) = @_;
my $re_h1 = '^\s+(random)' . ('\s+(\S+)' x 4);
my $re_h2 = '^\s+(KB)' . ('\s+(\S+)' x 14);
my @headers;
my @html= ("");
while (<$fh>) {
chomp;
my @cap;
if (@cap = /$re_h1/o) {
@headers = ("", "", "", "", "", "", @cap, "", "", "", "");
} elsif (@cap = /$re_h2/o) {
push(@html, "\n ");
for my $i (0 .. $#headers) {
push(@html, " $headers[$i] $cap[$i] | ");
}
push(@html, "
");
last;
} else {
push(@html, $_);
}
}
return join("\n", @html);
}
sub print_table {
my $num_columns = @{$data[0]->[0]->[0]};
for my $row (0 .. @{$data[0]->[0]}-1) {
print " \n";
for my $column (0 .. 1) {
printf(" | %d | \n",
$data[0]->[0]->[$row]->[$column]);
}
for my $column (2 .. $num_columns-1) {
my $val_a = avg_value($data[0], $row, $column);
my $val_b = avg_value($data[1], $row, $column);
printf(" %d %d | \n",
danger_colour($val_a, $val_b), $val_a, $val_b);
}
print "
\n";
}
print "
\n