HDBench のデータmyvideo.txtを性能順にソートする

perl sort_uniq_myvideo.pl myvideo.txt

# -_-* perl *-_-
use strict;
use utf8;
use Data::Dumper;

$| = 1;

my @lines = <>;
my @datas = ();

@lines = map { chomp; s/^ +//; s/ +$//; $_; } @lines;
while(@lines)
{
	my %topic;
	$topic{VideoCard} = shift @lines;
	$topic{Processor} = shift @lines;
	$topic{Rectangle} = shift @lines;
	$topic{Text} = shift @lines;
	$topic{Ellipse} = shift @lines;
	$topic{BitBlt} = shift @lines;

	push @datas,\%topic;
}

# print Dumper [\@datas];
my %bak;
print STDERR <<__TEXT;

====================
===  MYVIDEO.TXT  ====
====================
__TEXT
foreach( sort { 
   $$b{Rectangle} + $$b{Text} + $$b{Ellipse} + $$b{BitBlt}
        <=>
   $$a{Rectangle} + $$a{Text} + $$a{Ellipse} + $$a{BitBlt}
    } @datas )
{
	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} eq $bak{Rectangle} 
	     and  $$_{Text}      eq $bak{Text}      
	     and  $$_{Ellipse}   eq $bak{Ellipse}   
	     and  $$_{BitBlt}    eq $bak{BitBlt}    );

	print "$$_{VideoCard}\n";
	print "$$_{Processor}\n";
	print "$$_{Rectangle}\n";
	print "$$_{Text}\n";
	print "$$_{Ellipse}\n";
	print "$$_{BitBlt}\n";
	%bak = %$_;
}