Created
March 21, 2012 15:49
-
-
Save kenjiskywalker/2148797 to your computer and use it in GitHub Desktop.
ベンチマークの集計の為に書いたえぐいヤツ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
package Iops; | |
sub new{ | |
my $pkg = shift; | |
bless{ | |
data => shift, | |
sum => 0, | |
count => 0, | |
},$pkg; | |
} | |
sub set_iops { | |
my $self = shift; | |
my @hoge = split(/ /, $self->{data}); | |
for my $hoge (@hoge){ | |
$self->{data} = "$hoge" if ($hoge =~ /iops/); | |
} | |
$self->{data} =~ s/[^0-9]+//; | |
$self->{data} =~ s/.*\=//m; | |
$self->{sum} += $self->{data}; | |
$self->{count}++; | |
} | |
sub ans_iops{ | |
my $self = shift; | |
$self->{sum} = ( $self->{sum} / $self->{count} ); | |
} | |
1; | |
package Sec; | |
sub new{ | |
my $pkg = shift; | |
bless{ | |
data => shift, | |
sum => 0, | |
count => 0, },$pkg; | |
} | |
sub set_sec { | |
my $self = shift; | |
my @hoge = split(/ /, $self->{data}); | |
for my $hoge (@hoge){ | |
$self->{data} = "$hoge" if ($hoge =~ /msec/); | |
} | |
$self->{data} =~ s/msec//; | |
$self->{sum} += $self->{data}; | |
$self->{count}++; | |
} | |
sub ans_sec { | |
my $self = shift; | |
$self->{sum} = ( $self->{sum} / $self->{count} ); | |
} | |
1; | |
package Bw; | |
sub new{ | |
my $pkg = shift; | |
bless{ | |
data => shift, | |
sum => 0, | |
count => 0, | |
},$pkg; | |
} | |
sub set_bw { | |
my $self = shift; | |
my @hoge = split(/ /, $self->{data}); | |
for my $hoge (@hoge){ | |
$self->{data} = "$hoge" if ($hoge =~ /bw/); | |
} | |
$self->{data} =~ s/[^0-9]+//g; | |
$self->{sum} += $self->{data}; | |
$self->{count}++; | |
} | |
sub ans_bw { | |
my $self = shift; | |
$self->{sum} = ( $self->{sum} / $self->{count} ); | |
} | |
1; | |
package Main; | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
my $iops = undef; | |
my $sec = undef; | |
my $bw = undef; | |
my @list = qw( randread16k randrw16k | |
randwrite16k read16k | |
write16k rw16k); | |
for my $list (@list) { | |
for my $n ( qw(4 8 16) ){ | |
print "| $list$n | "; | |
# my $file = "/root/script/$list$n"; | |
my $file = "./iofile"; | |
open my $fh , '<', $file | |
or die warn $!; | |
while (my $line = <$fh>) { | |
if ( $line =~ /iops\=/ ) { | |
$iops = Iops->new($line); | |
$iops->set_iops; | |
} | |
if ( $line =~ /runt\=/ ) { | |
$sec = Sec->new($line); | |
$sec->set_sec; | |
}; | |
if ( $line =~ /bw\=/ ) { | |
$bw = Bw->new($line); $bw->set_bw; | |
}; | |
}; | |
$iops->ans_iops; | |
$sec->ans_sec; | |
$bw->ans_bw; | |
print " iops | $iops->{sum} | sec | $sec->{sum}msec | bw | $bw->{sum}KB/s | \n"; | |
} | |
print "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment