HDBENCHのmycpuとmyvideo更新スクリプト
いろいろめんどうだったので結合
遅すぎたので修正
HDD の解析もいれた が適当
# -_-* perl *-_- use strict; use utf8; use Data::Dumper; $| = 1; my @lines = (); my @datas = (); while(<>) { chomp; s/^ +//; s/ +$//; next if( /^$/ ); push @lines, $_; } my %bak = (); while(@lines) { $_ = shift @lines; if( /HDBENCH Ver 3/ ) { my @bak; for( 0 .. 50 ) { push @bak , @lines[$_]; } my %topic; &HDBENCH3406(\@bak, \%topic); push @datas,\%topic; } print STDERR "READ UNFORMAT DATA line:$#lines / Entry:$#datas \r"; } print STDERR "\n"; # print Dumper [\@datas]; #==================== #=== read old data . ==== #==================== ## read old data . open my $rfh, '<', "mycpu.txt"; my $i = 0; my @temp = (); while(<$rfh>) { chomp; s/^ +//; s/ +$//; # next if( /^$/ ); push @temp, $_; } while(@temp) { my %topic; $topic{Processor} = shift @temp; $topic{Integer} = shift @temp; $topic{Float} = shift @temp; push @datas,\%topic; $i++; print STDERR "READ CPU DATA remin:$#temp / Entrys:$i/$#datas \r"; } close $rfh; print STDERR "\n"; ## open my $rfh, '<', "myvideo.txt"; my $i = 0; my @temp = (); while(<$rfh>) { chomp; s/^ +//; s/ +$//; # next if( /^$/ ); push @temp, $_; } while(@temp) { my %topic; $topic{VideoCard} = shift @temp; $topic{Processor} = shift @temp; $topic{Rectangle} = shift @temp; $topic{Text} = shift @temp; $topic{Ellipse} = shift @temp; $topic{BitBlt} = shift @temp; push @datas,\%topic; $i++; print STDERR "READ VIDEO DATA remin:$#temp / Entrys:$i/$#datas \r"; } close $rfh; print STDERR "\n"; ## open my $rfh, '<', "myhdd.txt"; my $i = 0; my @temp = (); while(<$rfh>) { chomp; s/^ +//; s/ +$//; # next if( /^$/ ); push @temp, $_; } while(@temp) { my %topic; $topic{HDD} = shift @temp; $topic{Controller} = shift @temp; $topic{Read} = shift @temp; $topic{Write} = shift @temp; $topic{RRead} = shift @temp; $topic{RWrite} = shift @temp; push @datas,\%topic; $i++; print STDERR "READ HDD DATA remin:$#temp / Entrys:$i/$#datas \r"; } close $rfh; print STDERR "\n"; ## #==================== #=== MYCPU.TXT ==== #==================== open my $wfh, '>', "mycpu.txt"; my $i = 0; my %bak = (); foreach( sort { $$b{Integer} + $$b{Float} <=> $$a{Integer} + $$a{Float} } @datas ) { next unless( $$_{Processor} ); next unless( $$_{Integer} ); next unless( $$_{Float} ); next unless( $$_{Integer} =~ /\d+/ ); next unless( $$_{Float} =~ /\d+/ ); next if ( $$_{Processor} eq $bak{Processor} and $$_{Integer} == $bak{Integer} and $$_{Float} == $bak{Float} ); print $wfh "$$_{Processor}\n"; print $wfh "$$_{Integer}\n"; print $wfh "$$_{Float}\n"; $i++; print STDERR "WRITE CPU DATA Entry:$i / Entrys:$#datas \r"; %bak = %$_; } close $wfh; print STDERR "\n"; ## #==================== #=== MYVIDEO.TXT ==== #==================== open my $wfh, '>', "myvideo.txt"; my $i = 0 ; my %bak = (); foreach( sort { $$b{Rectangle} + $$b{Text} + $$b{Ellipse} + $$b{BitBlt} <=> $$a{Rectangle} + $$a{Text} + $$a{Ellipse} + $$a{BitBlt} } @datas ) { next unless( $$_{VideoCard} ); next unless( $$_{Rectangle} ); next unless( $$_{Text} ); next unless( $$_{Ellipse} ); next unless( $$_{BitBlt} ); next unless( $$_{Rectangle} =~ /\d+/ ); next unless( $$_{Text} =~ /\d+/ ); next unless( $$_{Ellipse} =~ /\d+/ ); next unless( $$_{BitBlt} =~ /\d+/ ); next if ( $$_{VideoCard} eq $bak{VideoCard} # and $$_{Processor} eq $bak{Processor} and $$_{Rectangle} == $bak{Rectangle} and $$_{Text} == $bak{Text} and $$_{Ellipse} == $bak{Ellipse} and $$_{BitBlt} == $bak{BitBlt} ); print $wfh "$$_{VideoCard}\n"; print $wfh "$$_{Processor}\n"; print $wfh "$$_{Rectangle}\n"; print $wfh "$$_{Text}\n"; print $wfh "$$_{Ellipse}\n"; print $wfh "$$_{BitBlt}\n"; $i++; print STDERR "WRITE VIDEO DATA Entry:$i / Entrys:$#datas \r"; %bak = %$_; } close wfh; print STDERR "\n"; ## #==================== #=== MYHDD.TXT ==== #==================== open my $wfh, '>', "myhdd.txt"; my $i = 0 ; my %bak = (); foreach( sort { $$b{Read} + $$b{Write} + $$b{RRead} + $$b{RWrite} <=> $$a{Read} + $$a{Write} + $$a{RRead} + $$a{RWrite} } @datas ) { # print "$$_{HDD}\n"; # print "$$_{Controller}\n"; next unless( $$_{HDD} ); next unless( $$_{Read} ); next unless( $$_{Write} ); # next unless( $$_{RRead} ); # next unless( $$_{RWrite} ); # print "$$_{Read}\n"; # print "$$_{Write}\n"; # print "$$_{RRead}\n"; # print "$$_{RWrite}\n"; next unless( $$_{Read} =~ /\d+/ ); next unless( $$_{Write} =~ /\d+/ ); next unless( $$_{RRead} =~ /\d+/ ); next unless( $$_{RWrite} =~ /\d+/ ); next if ( $$_{HDD} eq $bak{HDD} and $$_{Controller} eq $bak{Controller} and $$_{Read} == $bak{Read} and $$_{Write} == $bak{Write} and $$_{RRead} == $bak{RRead} and $$_{RWrite} == $bak{RWrite} ); print $wfh "$$_{HDD}\n"; print $wfh "$$_{Controller}\n"; print $wfh "$$_{Read}\n"; print $wfh "$$_{Write}\n"; print $wfh "$$_{RRead}\n"; print $wfh "$$_{RWrite}\n"; $i++; print STDERR "WRITE HDD DATA Entry:$i / Entrys:$#datas \r"; %bak = %$_; } close wfh; print STDERR "\n"; ## #########################################3 sub HDBENCH3406 { my $read = shift; my $data = shift; my $key1_en = 0; my $hdd_en = 0; my @topic = ( 'M/B\sName', 'Processor', 'VideoCard', 'Resolution', 'Memory', 'OS', 'Date' ); my @key1 = qw/ ALL Integer Float MemoryR MemoryW MemoryRW DirectDraw /; my @key2 = qw/ Rectangle Text Ellipse BitBlt Read Write RRead RWrite Drive /; while(@$read) { my $key0_en = 0; $_ = shift @$read; next if( /^$/ ); foreach my $topic( @topic ) { # print "$topic -- $_\n" unless ( m#^$topic\s*#x ); # print "$topic ++ $_\n" if ( m#^$topic\s*#x ); # print "$topic : $'\n" if ( m#^$topic#x ) { # warn "$topic : $$data{$topic} to $'\n" if( $$data{$topic} and $$data{$topic} ne $' ); $$data{$topic} = $'; $$data{$topic} =~ s/^\s+//; $key0_en++; next; } } next unless( $key0_en == 0 ); # my @col = split(/\s+/, $_); my @diff = grep { !{map{$_,1}@key1 }-> {$_}}@col; unless( @diff ) { val($read, \@key1, $data); $key1_en = 1; next; } # print "$key0_en $_\n"; my @diff = grep { !{map{$_,1}@key2 }-> {$_}}@col; unless( @diff ) { val($read, \@key2, $data); last; } # hdd? てけとー my $content_line = join( ' ' , @col ); if( $key1_en != 1 ) { if( $content_line =~ /(Controller|ATA|IDE)/ ) { $$data{Controller} = $content_line; # print "$$data{Controller} Controller\n"; } elsif( $content_line !~ /(DVD|CD)/ ) { $$data{HDD} = $content_line; } } } return; } sub val { my $read = shift; my $key = shift; my $topic = shift; $_ = shift @$read; chomp; s/^ +//; s/ +$//; my @col = split(/\s+/, $_); my $i = 0; foreach( @col ) { # print $$key[$i], "#" , $_, "\n"; $$topic{$$key[$i]} = $_; $i++; } }