📄 stat.hpp
字号:
* * @return 0 if the action is known * -1 else */ int computeRtt ( unsigned long P_start_time, double P_stop_time); /** * Get_current_counter_call Methods is used to get the number of current call * * @return 0 if the action is known * -1 else */ int get_current_counter_call (); /** * GetStat Method is used to retrieve a counter value * * @return the counter value **/ unsigned long GetStat (E_CounterName P_counter); /** * formatTime. * * This method converts a struct timeval parameter into a printable string * in the format given in parameter. * * @param P_tv. * @return a pointer on a static string containing formated time */ char* formatTime (struct timeval* P_tv); /** * setRepartitionCallLength * - set the unsigned int table passed in parameter as the repartition table * for call length. This is done by calling the initRepartition methode on * the M_CallLengthRepartition variable. * - set the char* list of int (must be separeted with coma as the * repartition table for call length * This is done by calling the createIntegerTable to transform the char* * list into unsigned int list. Then the initRepartition methode is * call with the created unsigned int list and the M_CallLengthRepartition * variable * * setRepartitionResponseTime * Same than setRepartitionCallLength with the variable * M_ResponseTimeRepartition variableinstead of M_CallLengthRepartition * variable */ void setRepartitionCallLength (unsigned int* repartition, int nombre); void setRepartitionCallLength (char * liste); void setRepartitionResponseTime (unsigned int* repartition, int nombre); void setRepartitionResponseTime (char * liste); /* define the file name to use to dump statistic in file */ void setFileName (char * name); void setFileName (char * name, char * extension); void initRtt (char * name, char * extension, unsigned long P_value); /** * Display data periodically updated on screen. */ void displayData (FILE *f); void displayStat(FILE *f); void displayRepartition(FILE *f); void displaySecondaryRepartition (FILE *f, int which); /** * Dump data periodically in the file M_FileName */ void dumpData (); void dumpDataRtt (); /** * initialize the class variable member */ int init();private: /** * Constructor. * * Made private because this is a singleton class. */ CStat (); /** * Destructor. * * Made private because this is a singleton class. */ ~CStat (); static CStat* M_instance; unsigned long M_counters[E_NB_COUNTER]; T_dynamicalRepartition* M_ResponseTimeRepartition[MAX_RTD_INFO_LENGTH]; T_dynamicalRepartition* M_CallLengthRepartition; int M_SizeOfResponseTimeRepartition; int M_SizeOfCallLengthRepartition; struct timeval M_startTime; struct timeval M_pdStartTime; struct timeval M_plStartTime; bool M_headerAlreadyDisplayed; char* M_fileName; ofstream* M_outputStream; bool M_headerAlreadyDisplayedRtt ; char* M_fileNameRtt ; ofstream* M_outputStreamRtt ; double M_time_ref ; T_pValue_rtt M_dumpRespTime ; int M_counterDumpRespTime ; unsigned long M_report_freq_dumpRtt ; unsigned long long M_C_sumCallLength; unsigned long long M_C_sumCallLength_Square; unsigned long long M_C_sumResponseTime[MAX_RTD_INFO_LENGTH]; unsigned long long M_C_sumResponseTime_Square[MAX_RTD_INFO_LENGTH]; unsigned long long M_PD_sumCallLength; unsigned long long M_PD_sumCallLength_Square; unsigned long long M_PD_sumResponseTime[MAX_RTD_INFO_LENGTH]; unsigned long long M_PD_sumResponseTime_Square[MAX_RTD_INFO_LENGTH]; unsigned long long M_PL_sumCallLength; unsigned long long M_PL_sumCallLength_Square; unsigned long long M_PL_sumResponseTime[MAX_RTD_INFO_LENGTH]; unsigned long long M_PL_sumResponseTime_Square[MAX_RTD_INFO_LENGTH]; /** * initRepartition * This methode is used to create the repartition table with a table of * unsigned int the reparition is created like following, with Vi the given * value in the table * 0 <= x < V1 * V1 <= x < V2 * ... * Vn-1 <= x < Vn * x >= Vn * So the repartition table have the size n+1 if the given table has a size * of n */ void initRepartition(unsigned int* repartition, int nombre, T_dynamicalRepartition ** tabRepartition, int* nbTab); /** * createIntegerTable * this method try to create a table of unsigned int with the list of char* * passed in parameters * if it succed, it's return true (1) * else it's return false (0) */ int createIntegerTable(char * P_listeStr, unsigned int ** listeInteger, int * sizeOfList); /** * isWellFormed * this method check if the char* passed in parameter in really a list of * integer separated with comma. * if yes, it's return true (1) * else, it's return false (0) */ int isWellFormed(char * P_listeStr, int * nombre); /** * updateRepartition * The methode look for the place to set the value passed in parameter * Once found, the associeted counter is incremented */ void updateRepartition( T_dynamicalRepartition* tabRepart, int sizeOfTab, unsigned long value); /** * displayRepartition * Display the repartition passed in parameter at the screen */ void displayRepartition(FILE *f, T_dynamicalRepartition * tabRepartition, int sizeOfTab); /** * sRepartitionHeader * return a string with the range description of the given repartition */ char* sRepartitionHeader(T_dynamicalRepartition * tabRepartition, int sizeOfTab, char* P_repartitionName); /** * sRepartitionInfo * return a string with the number of value in the differente range of the * given repartition */ char* sRepartitionInfo(T_dynamicalRepartition * tabRepartition, int sizeOfTab); /** * UpdateAverageCounter * This methode compute the real moyenne with the passed value on the given * counter */ void updateAverageCounter(E_CounterName P_AverageCounter, E_CounterName P_NbOfCallUsed, E_CounterName P_Squares, unsigned long long* P_sum, unsigned long long* P_sq, unsigned long P_value); /** * computeStdev * This method computes the standard deviation using our recorded mean * and recorded mean square. */ unsigned long computeStdev(E_CounterName P_AverageCounter, E_CounterName P_NbOfCallUsed, E_CounterName P_Squares); /** * computeDiffTimeInMs. * * This method calculates elaped time in ms * * @param tf = final date * @param ti = initial date * * @return number of ms between the 2 dates */ long computeDiffTimeInMs (struct timeval* tf, struct timeval* ti); /** * msToHHMMSS. * * This converts an unsigned long containing a number of ms * into a string expressing the same value in format HH:MM:SS. * * @param P_ms. * * @return a pointer on a static string containing formated time */ char* msToHHMMSS (unsigned long P_ms); /** * msToHHMMSSmm. * * This converts an unsigned long containing a number of ms * into a string expressing the same value in format HH:MM:SS:mmm. * * @param P_ms. * * @return a pointer on a static string containing formated time */ char* msToHHMMSSmmm (unsigned long P_ms); /** * Effective C++ * * To prevent public copy ctor usage: no implementation */ CStat (const CStat&); /** * Effective C++ * * To prevent public operator= usage: no implementation */ CStat& operator=(const CStat&);};#endif // __STAT_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -