Medium sized Internalization made by flattener against megalog-2018-07-17
[andk-cpan-tools.git] / bin / compare-iozone-tables.pl
blob626d3b90b3152cf637b99099f209743ce23f115e
1 #!/usr/bin/perl
3 # use 5.010;
4 use strict;
5 use warnings;
7 =head1 NAME
11 =head1 SYNOPSIS
13 compare-iozone-tables file1 file2 ...
15 =head1 OPTIONS
17 =over 8
19 =cut
21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
23 =item B<--help|h!>
25 This help
27 =back
29 =head1 DESCRIPTION
31 The two or more files are compared cell by cell.
33 =cut
36 use FindBin;
37 use lib "$FindBin::Bin/../lib";
38 BEGIN {
39 push @INC, qw( );
42 use Dumpvalue;
43 use File::Basename qw(dirname);
44 use File::Path qw(mkpath);
45 use File::Spec;
46 use File::Temp;
47 use Getopt::Long;
48 use Pod::Usage;
49 use Hash::Util qw(lock_keys);
51 our %Opt;
52 lock_keys %Opt, map { /([^=|!]+)/ } @opt;
53 GetOptions(\%Opt,
54 @opt,
55 ) or pod2usage(1);
56 if ($Opt{help}) {
57 pod2usage(0);
60 our $S;
61 my $longest_table_name = 0;
62 for my $i (0..$#ARGV) {
63 my($file) = $ARGV[$i];
64 open my $fh, $file or die "Could not open '$file': $!";
65 my $in_excel = 0;
66 my $curtable = "";
67 my @columns = ();
68 LINE: while (<$fh>) {
69 if (/Excel output is below/) {
70 $in_excel = 1;
71 next LINE;
73 if (/^"(.+?)"$/) { # "Writer report"
74 $curtable = $1;
75 $curtable =~ s/\sreport$//;
76 $curtable =~ s/\s+/_/g;
77 if (length $curtable > $longest_table_name) {
78 $longest_table_name = length $curtable;
80 next LINE;
81 } elsif (/^\s+(".+"$)/) { # "4" "8" "16" "32" ...
82 @columns = map { /"(\d+)"/ } split " ", $1;
83 next LINE;
84 } elsif (/^"(.+?)"\s+([\d\s]+)$/) { # "2048" 219 358 365 347 ...
85 my($curline) = $1;
86 my(@curval) = split " ", $2;
87 for my $j (0..$#curval) {
88 $S->{$curtable}{$curline}{$columns[$j]}[$i] = $curval[$j];
94 for my $table (sort keys %$S) {
95 my $v = $S->{$table};
96 my @tablesum;
97 for my $line (sort {$a <=> $b} keys %$v) {
98 my $v2 = $v->{$line};
99 for my $col (sort {$a <=> $b} keys %$v2) {
100 my $val = $v2->{$col};
101 my $line = sprintf "%-*s %6d %5d", $longest_table_name, $table, $line, $col;
102 for my $i (0..$#$val) {
103 if ($i == 0) {
104 $line .= sprintf " %7d", $val->[$i];
105 } else {
106 my $growth;
107 if ($val->[$i-1] > 0) {
108 $growth = sprintf " %4d%%", 100 * $val->[$i] / $val->[$i-1] - 100;
109 } else {
110 $growth = "N/A";
112 $line .= sprintf " %8s %7d", $growth, $val->[$i];
114 $tablesum[$i] += $val->[$i];
116 print "$line\n";
119 my $line = sprintf "tablesum %-*s", $longest_table_name, $table;
120 for my $i (0..$#tablesum) {
121 if ($i == 0) {
122 $line .= sprintf " %8d", $tablesum[$i];
123 } else {
124 my $growth;
125 if ($tablesum[$i-1] > 0) {
126 $growth = sprintf " %4d%%", 100 * $tablesum[$i] / $tablesum[$i-1] - 100;
127 } else {
128 $growth = "N/A";
130 $line .= sprintf " %8s %8d", $growth, $tablesum[$i];
133 print "$line\n";
136 # Local Variables:
137 # mode: cperl
138 # cperl-indent-level: 4
139 # End: