#!/bin/awk -f
BEGIN {
    filename="";
    version="";
    versionList[""]="";
    run=1;   
    times[""]="";
  	num_capacity=split("0 1000000 2000000 4000000 8000000 12000000 16000000 ",capacityList," ");
    n=0;
    thread=0;
    machine[""]="";
    jvm="";
    jstar="";
    gc[""]="";
    gamma=""; 
    num_gamma=split("HashMap ConcurrentHashMap ConcurrentHashMapV8",gammaList," ");
}
{
 
    if(filename != FILENAME){
		filename=FILENAME;
		n=split(filename,array,".");
		version=array[1];
		versionList[version]=version;	
		gamma=array[2];
		thread=substr(array[3],7,length(array[3])+1);
		capacity=array[4];
		run=1;
    }

    if($0 ~ "Execution time:"){
		split($0,array," ");
		key=version","gamma","thread","capacity","run;
		times[key]=array[3];
		#printf("%s %s\n",key,times[key]);
		run++;
    }else{
		if(match($0,"*.GC.*")){
			gc[gamma","run]=$0;
		}else{
			if(match($0, "Linux.*")){
			    machine["OS"]=substr($0,1,index($0,"#"));
			}else if(match($0, "processor")){
			    split($0,array," ");
			    machine["processor"]=array[3];
			}else  if(match($0, "model name")){
			    split($0,array,":");
			    machine["model"]=array[2];
			}else if(match($0, "MemTotal:")){
			    split($0,array," ");
			    machine["memtotal"]=array[2];
			}else if(match($0, "====.*")){
			    machine["header"]=$0
			}else if(match($0, "java.*")){
			    split($0, array," ");
			    machine["jvm"]=array[2]"\t"array[3]"\t"array[4]"\t"array[5]"\t";
			    machine["jstar"]=array[8]"\t"array[9]"\t"array[10]"\t"array[11]"\t"array[12]"\t"array[13]"\t"array[14]"\t"array[15];
			}
		}
    }  
   
}
END {
    
    for(version in versionList){
    	for(g=1;g<=num_gamma;g++){
    		gamma=gammaList[g];
			key=version","gamma",1,"1000000","1;
			#printf("%s %s\n",key,times[key]);
			if(times[key] != ""){
				printf("Machine: %s with %d cores (%s) and %s memory\n",machine["OS"],int(machine["processor"])+1,machine["model"],machine["memtotal"]);
			    printf("Version:%s\tGamma:%s\n",version,gamma,capacity);
			    printf("\nCapacity:");
			    for(c=1;c<=num_capacity;c++){
			    	printf("\t%s",capacityList[c]);
			   	}
				printf("\n");
				
				for(run=1;run<=30;run++){
					printf("Run%s",run);			
					for(c=1;c<=num_capacity;c++){
						capacity=capacityList[c];
					    key=version","gamma","thread","capacity","run;
					    printf("\t%s",times[key]);
					}
					printf("\n");
			    }
			    
			    printf("\nVersion:");
			    for(c=1;c<=num_capacity;c++){
			   	    printf("\t%s",version);
			    }
			    
			    printf("\nPvWattsGamma:");
			    for(c=1;c<=num_capacity;c++){
				    printf("\t%s",gamma);
			    }
			    
			    printf("\nCapacity:");
			    for(c=1;c<=num_capacity;c++){
				    printf("\t%s",capacityList[c]);
			    }
			   						   
			    printf("\nAverage6-30");
			    printf("\nMedian6-30");
			    printf("\nVariance6-30");
			    printf("\nSpeedup");
			    printf("\n");
			}
		}
	}
}