// add the following to a cpp file: // PerformanceData PD; #pragma once #include using namespace std; enum PerformanceDataType { PD_DISPLAY=0, PD_SPS, PD_UNUSED0, //my stuff SIMULATE_SPECTRUM, SIMULATE_GPU, KRAMERS_KRONIG, //end my stuff PERFORMANCE_DATA_TYPE_COUNT }; static char PDTypeNames[][255] = { "Display ", "Simulation Total ", " ----------------- ", //my stuff "Simulate Spectrum ", " GPU Portion ", "Kramers-Kronig ", //end my stuff }; #ifdef WIN32 #include #include #include #include #include //------------------------------------------------------------------------------- class PerformanceData { public: PerformanceData() { ClearAll(); QueryPerformanceFrequency(&cps); } ~PerformanceData() {} void ClearAll() { for ( int i=0; i maxTime[type] ) maxTime[type] = t; totalTime[type] -= times[type][ pos[type] ]; times[type][ pos[type] ] = t; totalTime[type] += t; pos[type]++; if ( pos[type] == 0 ) dataReady[type] = true; } void PrintResult( ostream &os,int i=PERFORMANCE_DATA_TYPE_COUNT) { os.setf(ios::fixed); if ((i=0)) { double a = GetAvrgTime(i); if ( a ) os<< PDTypeNames[i]<<" : avrg="<