#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
my ($DIR, $UNIT) = @ARGV;
if (not defined $DIR) {
die "Need directory: $0
\n";
}
if (not defined $UNIT) {
$UNIT = 1.0;
} else {
if ( $UNIT eq 'GB' ) {
$UNIT = 0.001;
}
}
my %RES;
my @testcases = ('Init', 'Sum', 'Copy', 'Update', 'Triad', 'Daxpy', 'STriad', 'SDaxpy');
while( defined( my $file = glob($DIR . '/*' ) ) ) {
my $nt = 1;
open(my $fh, "<","$file");
if ($file =~ /.*-([0-9]+)\.txt/) {
$nt = $1;
}
$RES{$nt} = {};
while ( <$fh> ) {
my $cnt = split(/[ ]+/, $_);
if ( $cnt == 6 ) {
my @fields = split(/[ ]+/, $_);
if ( $fields[1] =~ /[0-9]+/ ) {
$fields[0] =~ s/://;
$RES{$nt}->{$fields[0]} = $fields[1] * $UNIT;
}
}
}
close $fh or die "can't close file $!";
}
printf "#nt";
foreach my $test ( @testcases ) {
printf "\t%s", $test;
}
printf "\n";
foreach my $key (sort {$a <=> $b} keys %RES) {
printf "%d", $key;
foreach my $test ( @testcases ) {
if ( $UNIT > 0.1 ) {
printf "\t%.0f", $RES{$key}->{$test};
} else {
printf "\t%.2f", $RES{$key}->{$test};
}
}
printf "\n";
}