#!/usr/bin/perl

use strict;
use Data::Dumper;


my %LoadMax		= ();
my $LoadMax		= {};

my %Quellen		= ();
my $Quellen		= {};

my %Treffer		= ();
my $Treffer		= {};


opendir(DIR, "benchmarks_DC");
my @files = grep(/\.csv$/,readdir(DIR));
closedir(DIR);

my $c = 0;
foreach my $file (@files) {

	my $text = "";
	open( FH, "<benchmarks_DC\\$file" ) or die "'$file' sudden flaming death: $!\n";
	{
		local $/;
		$text = <FH>;
	}
	close FH;

	my @content = split(";", $text);

	for ( my $i=0; $i<=scalar(@content); $i++ ) {
	
		my $string = $content[$i];
		## print "$string \n";

		if ( $string =~ /Load Proxy max\./i ) {
			
			my $stringPlus = $content[$i+1];
			$LoadMax{$stringPlus}++;
		#	print "'$string' und '$stringPlus'\n";

		}; # if ( $string =~ /Load Proxy max./i ) {
	
		if ( $string =~ /Mittelwert Quellen/i ) {
			
			my $stringPlus = $content[$i+1];
			$Quellen{$stringPlus}++;
		#	$Quellen += $stringPlus;
		#	print "[$c] Quellen $Quellen\n";

		}; # if ( $string =~ /Mittelwert Quellen/i ) {
	
		if ( $string =~ /Mittelwert Treffer/i ) {
			
			my $stringPlus = $content[$i+1];
			$Treffer{$stringPlus}++;
		#	$Treffer += $stringPlus;
		#	print "[$c] Treffer $Treffer\n";

		}; # if ( $string =~ /Mittelwert Treffer/i ) {

	}; # for ( my $i=0; $i<=0 ; $i++ ) {

	$c++;

}; # foreach my $file (@files) {




my @sorted1 = sort { $LoadMax{$a} <=> $LoadMax{$b} } keys %LoadMax; 
#print "Max Load was $sorted1[0]\n"; 

my @sorted2 = sort { $Quellen{$a} <=> $Quellen{$b} } keys %Quellen; 
#print "Max Quellen was $sorted2[0]\n"; 

my @sorted3 = sort { $Treffer{$a} <=> $Treffer{$b} } keys %Treffer; 
#print "Max Treffer was $sorted3[0]\n"; 

print Dumper %Treffer;



exit;

foreach my $value1 ( sort { $LoadMax{$b} <=> $LoadMax{$a} } keys %LoadMax ) {
	print "Max Load was $value1\n";
	last;
};

foreach my $value2 ( sort { $Quellen{$b} <=> $Quellen{$a} } keys %Quellen ) {
	print "Max Quellen was $value2\n";
	last;
};

foreach my $value3 ( sort { $Treffer{$b} <=> $Treffer{$a} } keys %Treffer ) {
	print "Max Treffer was $value3\n";
	last;
};


# print Dumper %Quellen;
#my $DurchschnittQuellen = $Quellen / $c;
#my $DurchschnittTreffer = $Treffer / $c;
#
#print "$c Durchschnitt Quellen: $DurchschnittQuellen\n";
#print "$c Durchschnitt Treffer: $DurchschnittTreffer\n";

