// add the following to a cpp file: // PerformanceData PD; #pragma once enum PerformanceDataType { PD_DISPLAY=0, PD_SPS, PD_UNUSED0, //my stuff SUBDIVIDE_NETWORKS, BRUTE_FORCE_DISTANCE, LOG_N_DIST_BUILD0, LOG_N_DIST_SEARCH0, LOG_N_DIST_BUILD1, LOG_N_DIST_SEARCH1, LOG_N_DISTANCE, MY_TOPOLOGY, BOOST_TOPOLOGY, //end my stuff PERFORMANCE_DATA_TYPE_COUNT }; static char PDTypeNames[][255] = { "Display ", "Simulation Total ", " ----------------- ", //my stuff "Network Subdivision", "Brute Force Dist.--", " Build 0 ", " Search 0 ", " Build 1 ", " Search 1 ", "ANN Dist.----------", "MY Topology--------", "BOOST Topology-----", //end my stuff }; //------------------------------------------------------------------------------- //#ifdef DISPLAY // #define PERFORMANCE_DATA_MEASUE_ENABLE //#endif //#ifdef PERFORMANCE_DATA_MEASUE_ENABLE //------------------------------------------------------------------------------- #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="<