void printPerformance(){ calculatePerformance(); printf("-------------------------\n"); printf("|Performance\t|Value\t|\n"); printf("-------------------------\n"); printf("|Average CPI\t|%.2f\t|\n", avgCPI); printf("-------------------------\n"); printf("|CPU Time (ms)\t|%.2f\t|\n", cpuTime); printf("-------------------------\n"); printf("|MIPS\t\t|%.2f\t|\n", mips); printf("-------------------------\n"); printf("\n"); }//printPerformance
void mSingleObj::outputResult(){ calculateKeyParam(); calculatePerformance(); int maxNumrun=MAX_NUM_RUN; if(0){//m_progrOutputFlag stringstream ss; ss<<Global::g_arg[param_workingDir]<<"Result/"<<m_fileName.str()<<"Progr.txt"; ofstream out(ss.str().c_str()); double *data=new double[maxNumrun]; vector<int> idx; stringstream oss; for(int i=0;i<m_numRecords;){ for(int j=0;maxNumrun>j;j++){ if(m_absoluteErr){ // absolute error(offline error) if(mpp_gOpt.size()>0) data[j]=fabs(mpp_data[j][i]-mpp_gOpt[j][i/m_recordsPerChange]); else data[j]=mpp_data[j][i]; }else{ double gap; if(m_comp==MIN_OPT) gap=fabs(mpp_data[j][m_recordsPerChange*(i+1)-1])+1; else gap=fabs(mpp_data[j][m_recordsPerChange*i])+1; if(m_comp==MIN_OPT){ ///Note: preprocess the data to make sure they are greater than 0 to avoid overflow error data[j]=1-(mpp_gOpt[j][i/m_recordsPerChange]+gap)/(mpp_data[j][i]+gap); }else{ data[j]=1-(mpp_data[j][i]+gap)/(mpp_gOpt[j][i/m_recordsPerChange]+gap); } } } gQuickSort<double*>(data,maxNumrun,idx); double x; if(m_convgMode==PROGR_MEAN){ x=0; for(int j=0;maxNumrun>j;j++) x+=data[idx[j]]; oss<<(i+1)*Global::g_arg[param_sampleFre]<<" " <<x/maxNumrun<<endl; }else if(m_convgMode==PROGR_MEDEAN){ oss<<(i+1)*Global::g_arg[param_sampleFre]<<" " <<data[idx[maxNumrun/2]]<<endl; }else if(m_convgMode==PROGR_WORST){ if(m_comp==MIN_OPT) oss<<(i+1)*Global::g_arg[param_sampleFre]<<" " <<data[idx[maxNumrun-1]]<<endl; else oss<<(i+1)*Global::g_arg[param_sampleFre]<<" " <<data[idx[0]]<<endl; }else if(m_convgMode==PROGR_BEST){ if(m_comp==MIN_OPT) oss<<(i+1)*Global::g_arg[param_sampleFre]<<" " <<data[idx[0]]<<endl; else oss<<(i+1)*Global::g_arg[param_sampleFre]<<" " <<data[idx[maxNumrun-1]]<<endl; }else{ //... } i++; try{ if(i%2000==0){ out<<oss.str(); oss.str(""); } } catch(...){ cout<<"memory allocation failer"<<endl; } } delete []data; out.close(); } stringstream ss; ss<<Global::g_arg[param_workingDir]<<"Result/"<<m_fileName.str()<<"Sta.txt"; ofstream out(ss.str().c_str()); out<<"Algorithm: "<<gGetAlgorithmName(Global::ms_curAlgId)<<endl; out<<"Algorithm Parameters: "<<m_algPar.str()<<endl; out<<"Number of runs: "<<maxNumrun<<endl; out<<"Problem: "<<gGetProblemName(Global::ms_curProId)<<endl; out<<"Problem Parameters: "<<m_proPar.str()<<endl; double mean, var, best, worst; getStatInfor(mean,var,worst,best); out<<"Mean of Best&STD over Runs: "<<m_meanOverRuns<<"+"<<m_meanOverRunsVar<<endl; out<<"Best: "<<best<<endl; out<<"Worst: "<<worst<<endl; out<<"Total evals: "<<m_avgTevals/maxNumrun<<endl; out<<"Countable evals: "<<m_avgCevals/maxNumrun<<endl; out<<"Useful evals: "<<m_avgEvals/maxNumrun<<endl; out << "Elapsed time(s): " << m_meanDuration << endl; if(mpp_gOpt.size()>0){ //out<<"ConvergeSpeed2GOpt: "<<m_speed2gOpt<<endl; // out<<"Sucess rate: "<<m_sucRate<<endl; out<<"Performance&STD: "<<m_performance<<"+"<<m_perfVar<<endl; out<<"Offline error over runs&STD: "<<m_offlineErrOverRuns<<"+"<<m_offlineErrOverRunsVar<<endl; } out.close(); ss.str(""); ss<<Global::g_arg[param_workingDir]<<"Result/"<<m_fileName.str()<<"Err.txt"; out.open(ss.str().c_str()); for(int i=0;maxNumrun>i;i++){ double err=0; for(int j=1;j<=m_numChanges;j++){ if(mpp_gOpt.size()>0) err+=fabs(mpp_data[i][j*m_recordsPerChange-1]-mpp_gOpt[i][j-1]); else err+=mpp_data[i][j*m_recordsPerChange-1]; } out<<err/m_numChanges<<endl; } out.close(); }