#include <SugoiTools\appli.h>
SugoiTools(d).lib SugoiTracer(d).lib
//C++ [TODO...] //C #ifdef _MY_APP_DO_PROFILING #include <SugoiTools\appli.h> //Main include file. #define _MY_APP_PROFILE(FCT) FCT // #define _MY_APP_START_RECORD(FCT_NAME) StartRecordingChar(CreateFunction(FCT_NAME), "VER", YOUR_APPLICATION_VERSION) #define _MY_APP_STOP_RECORD(FCT_ID) StopRecording(FCT_ID) #define _MY_APP_ADDPARAM(FCT) FCT #else #define _MY_APP_DOPROFILE(FCT) #define _MY_APP_START_RECORD(FCT_NAME) #define _MY_APP_STOP_RECORD(FCT_ID) #define _MY_APP_ADDPARAM(FCT) #endif
return XMLLoadBench(Filename);
return XMLSaveBench(Filename);
... #include <SG_TRC_appli.h> //include the main header file. ... int main() { //Create main application profiler TTCL_APPLI_TRACER * AppliProfiler = new TTCL_APPLI_TRACER(); //now you can profile your functions... ... }
//this will save your records into a file using the date, so you can check the evolution of your work. std::string FileName = "Bench -"; FileName += __DATE__; TTCL_APPLI_TRACER<CL_TimerVal>::MainAppliTracer->XMLSaveToFile(FileName.data());
void FunctionToProfile(....) { //I suggest you to use preprocessor branching for profiling, so you can easily disable it in your release builds. #if SUPPORT_BENCHMARK //Here, we create a static handler to the CL_FUNCTION_TRC object representing this function. //we use the main TTCL_APPLI_TRACER object for this operation and call the AddFunct with the name of our function. //this part of code will only be executed once, the first time we get into FunctionToProfile(). static SG_TRC_FUNCT_BY_TIME = TTCL_APPLI_TRACER<CL_TimerVal>::MainAppliTracer->AddFunct("FunctionToProfile"); //Now we create a temporary tracer(CL_TEMP_TRACER) object, and we give him the handler to this function 'ThisFct'. //The second parameter will stay NULL, we will see later how to use it. //When creating a CL_TEMP_TRACER, a CL_TRACER is automatically created and start recording time. SG_TRC_TEMP_TRACER_BY_TIME (ThisFct, NULL); #endif //code of the function ... ... //when we leave FunctionToProfile(), 'Tracer' will be automatically destroyed and this will stop the timer and save a record. }
_MY_APP_DOPROFILE(int FctProfileId = _ART_START_RECORD("MY_FCT_NAME"));
_MY_APP_ADDPARAM(AddParamInt(FctProfileId, "width", img_width);); _MY_APP_ADDPARAM(AddParamChar(FctProfileId, "filename", img_filename););
_MY_APP_STOP_RECORD(ProfileId);
If the profiled function is inside a loop, it may be more efficient (in processing Time) to profile the loop and store the number of loop as a parameter. It is not possible in all case.
void FunctionToProfile(char * _stringValue1, int _intValue1) { #if SUPPORT_BENCHMARK static SG_TRC_FUNCT_BY_TIME = TTCL_APPLI_TRACER<CL_TimerVal>::MainAppliTracer->AddFunct("FunctionToProfile"); //Before creating the temp tracer, we are going to create a temp argumement CL_TRACE_BASE_PARAMS with a std::string argument. CL_TRACE_BASE_PARAMS * TempParams = new CL_TRACE_BASE_PARAMS("argDescription1", _stringValue1); //then we had an integer argument : TempParams->AddInt ("argDescription2", &_intValue1, 1); //then we create a CL_TEMP_TRACER with the right parameters. SG_TRC_TEMP_TRACER_BY_TIME (ThisFct, TempParams); #endif //code of the function ... ... //When destroying Tracer, the record will be stored with the right parameters. }