⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stat.cpp

📁 sipp is sip protocal testing tool.
💻 CPP
📖 第 1 页 / 共 4 页
字号:
      // Updating Periodical Diplayed counter      updateAverageCounter((E_CounterName)(CPT_PD_AverageResponseTime + which),                            (E_CounterName)(CPT_PD_NbOfCallUsedForAverageResponseTime + which),                           (E_CounterName)(CPT_PD_AverageResponseTime_Squares + which),                           &M_PD_sumResponseTime[which], &M_PD_sumResponseTime_Square[which], P_value);      // Updating Periodical Logging counter      updateAverageCounter((E_CounterName)(CPT_PL_AverageResponseTime + which),                            (E_CounterName)(CPT_PL_NbOfCallUsedForAverageResponseTime + which),                           (E_CounterName)(CPT_PL_AverageResponseTime_Squares + which),                           &M_PL_sumResponseTime[which], &M_PL_sumResponseTime_Square[which], P_value);      break;    default :      ERROR_P1("CStat::ComputeStat() - Unrecognized Action %d\n", P_action);      return (-1);    } /* end switch */  return (0);}void CStat::updateRepartition(T_dynamicalRepartition* P_tabReport,                               int P_sizeOfTab,                               unsigned long P_value){  bool found;  int i;  if(P_tabReport != NULL)    {      i = P_sizeOfTab-2;      found = false;      while((found == false) && (i>=1))        {          if( (P_value < P_tabReport[i].borderMax) &&              (P_tabReport[i-1].borderMax <= P_value) )            {              found = true;              P_tabReport[i].nbInThisBorder ++;            }          i--;        }          if(!found)        {          if(P_value < P_tabReport[0].borderMax)            {              P_tabReport[0].nbInThisBorder ++;            }          else if(P_value >= P_tabReport[P_sizeOfTab-1].borderMax)            {              P_tabReport[P_sizeOfTab-1].nbInThisBorder ++;            }          else            {              // ERROR !!!!              printf("\n ERROR - Unable to sort this Value in "                     "the repartition table! %d \n", P_value);            }        }    }}CStat::CStat (){  size_t L_size = 0;  L_size += strlen(DEFAULT_FILE_NAME) ;  L_size += strlen(DEFAULT_EXTENSION) ;  L_size += 1 ;  M_fileName = new char[L_size];  strcpy(M_fileName, DEFAULT_FILE_NAME);  strcat(M_fileName, DEFAULT_EXTENSION);  for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) {    M_ResponseTimeRepartition[i] = NULL;  }  M_CallLengthRepartition   = NULL;  M_SizeOfResponseTimeRepartition = 0;  M_SizeOfCallLengthRepartition   = 0;  M_fileNameRtt = NULL;  M_time_ref = 0.0                   ;  M_dumpRespTime = NULL              ;  M_counterDumpRespTime = 0          ;   M_dumpRespTime = NULL;  M_fileNameRtt  = NULL;  init();}CStat::~CStat (){}char* CStat::sRepartitionHeader(T_dynamicalRepartition * tabRepartition,                                 int sizeOfTab,                                 char * P_repartitionName){  static char  repartitionHeader[MAX_REPARTITION_HEADER_LENGTH];  char buffer[MAX_CHAR_BUFFER_SIZE];  if(tabRepartition != NULL)    {      sprintf(repartitionHeader, "%s%s", P_repartitionName, stat_delimiter);      for(int i=0; i<(sizeOfTab-1); i++)        {             sprintf(buffer, "<%d%s", tabRepartition[i].borderMax, stat_delimiter);          strcat(repartitionHeader, buffer);        }      sprintf(buffer, ">=%d%s", tabRepartition[sizeOfTab-1].borderMax, stat_delimiter);      strcat(repartitionHeader, buffer);    }  else    {      sprintf(repartitionHeader, "");    }  return(repartitionHeader);}char* CStat::sRepartitionInfo(T_dynamicalRepartition * tabRepartition,                               int sizeOfTab){  static char repartitionInfo[MAX_REPARTITION_INFO_LENGTH];  char buffer[MAX_CHAR_BUFFER_SIZE];  if(tabRepartition != NULL)    {      // if a repartition is present, this field match the repartition name      sprintf(repartitionInfo, stat_delimiter);      for(int i=0; i<(sizeOfTab-1); i++)        {             sprintf(buffer, "%d%s", tabRepartition[i].nbInThisBorder, stat_delimiter);          strcat(repartitionInfo, buffer);        }      sprintf(buffer, "%d%s", tabRepartition[sizeOfTab-1].nbInThisBorder, stat_delimiter);      strcat(repartitionInfo, buffer);    }  else    {      sprintf(repartitionInfo, "");    }  return(repartitionInfo);}void CStat::displayRepartition(FILE *f,                               T_dynamicalRepartition * tabRepartition,                                int sizeOfTab){  if(tabRepartition != NULL) {    for(int i=0; i<(sizeOfTab-1); i++) {         if(i==0) {        DISPLAY_REPART(0, tabRepartition[i].borderMax,                         tabRepartition[i].nbInThisBorder);      } else {        DISPLAY_REPART(tabRepartition[i-1].borderMax,                        tabRepartition[i].borderMax,                        tabRepartition[i].nbInThisBorder);      }    }    DISPLAY_LAST_REPART (tabRepartition[sizeOfTab-1].borderMax,                          tabRepartition[sizeOfTab-1].nbInThisBorder);  } else {    DISPLAY_INFO ("  <No repartion defined>");  }}void CStat::displayData (FILE *f){  char   buf1 [64], buf2 [64], buf3 [64];  long   localElapsedTime, globalElapsedTime ;  struct timeval currentTime;  float  averageCallRate;  float  realInstantCallRate;  unsigned long numberOfCall;  GET_TIME (&currentTime);  // computing the real call rate  globalElapsedTime   = computeDiffTimeInMs (&currentTime, &M_startTime);  localElapsedTime    = computeDiffTimeInMs (&currentTime, &M_pdStartTime);  // the call rate is for all the call : incoming and outgoing  numberOfCall        = M_counters[CPT_C_IncomingCallCreated] +     M_counters[CPT_C_OutgoingCallCreated];  averageCallRate     = (globalElapsedTime > 0 ?                          1000*(float)numberOfCall/(float)globalElapsedTime                          : 0.0);  numberOfCall        = (M_counters[CPT_PD_IncomingCallCreated] +                          M_counters[CPT_PD_OutgoingCallCreated]);  realInstantCallRate = (localElapsedTime  > 0 ?                          1000*(float)numberOfCall / (float)localElapsedTime :                         0.0);  // display info  DISPLAY_DLINE ();  // build and display header info  DISPLAY_TXT ("Start Time  ", formatTime(&M_startTime));  DISPLAY_TXT ("Last Reset Time", formatTime(&M_pdStartTime));  DISPLAY_TXT ("Current Time", formatTime(&currentTime));  // printing the header in the middle  DISPLAY_CROSS_LINE();  DISPLAY_HEADER();  DISPLAY_CROSS_LINE();  DISPLAY_TXT_COL ("Elapsed Time",                    msToHHMMSSmmm(localElapsedTime),                      msToHHMMSSmmm(globalElapsedTime));  DISPLAY_VAL_RATEF_COL ("Call Rate",                           realInstantCallRate,                          averageCallRate);  DISPLAY_CROSS_LINE ();  DISPLAY_2VAL  ("Incoming call created",                  M_counters[CPT_PD_IncomingCallCreated],                 M_counters[CPT_C_IncomingCallCreated]);  DISPLAY_2VAL  ("OutGoing call created",                  M_counters[CPT_PD_OutgoingCallCreated],                 M_counters[CPT_C_OutgoingCallCreated]);  DISPLAY_CUMUL ("Total Call created", M_counters[CPT_C_IncomingCallCreated] +                 M_counters[CPT_C_OutgoingCallCreated]);  DISPLAY_PERIO ("Current Call",       M_counters[CPT_C_CurrentCall]);  bool first = true;  for (int i = 0; i < MAX_COUNTER; i++) {    char s[20];    if (M_counters[CPT_C_Generic + i] == 0) {      continue;    }    if (first) {      DISPLAY_CROSS_LINE ();      first = false;    }    sprintf(s, "Generic counter %d", i + 1);    DISPLAY_2VAL(s, M_counters[CPT_PD_Generic + i], M_counters[CPT_C_Generic + i]);  }  DISPLAY_CROSS_LINE ();  DISPLAY_2VAL  ("Successful call",                  M_counters[CPT_PD_SuccessfulCall],                  M_counters[CPT_C_SuccessfulCall]);  DISPLAY_2VAL  ("Failed call",                       M_counters[CPT_PD_FailedCall],                  M_counters[CPT_C_FailedCall]);  // DISPLAY_2VAL  ("Unexpected msg",     //                 M_counters[CPT_PD_UnexpectedMessage],   //                 M_counters[CPT_C_UnexpectedMessage]);  DISPLAY_CROSS_LINE ();  for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) {    char s[15];    if (M_counters[CPT_C_NbOfCallUsedForAverageResponseTime +i ] == 0) {      continue;    }    sprintf(s, "Response Time %d", i + 1);    DISPLAY_TXT_COL (s,	msToHHMMSSmmm( M_counters [CPT_PD_AverageResponseTime + i] ),	msToHHMMSSmmm( M_counters [CPT_C_AverageResponseTime + i] ));  }  DISPLAY_TXT_COL ("Call Length",                    msToHHMMSSmmm( M_counters [CPT_PD_AverageCallLength] ),                    msToHHMMSSmmm( M_counters [CPT_C_AverageCallLength] ));  DISPLAY_CROSS_LINE ();  for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) {    char s[50];    if (M_counters[CPT_C_AverageResponseTime + i] == 0) {      continue;    }    sprintf(s, "Average Response Time Repartition, %d", i + 1);    DISPLAY_INFO(s);    displayRepartition(f, M_ResponseTimeRepartition[i], M_SizeOfResponseTimeRepartition);  }  DISPLAY_INFO("Average Call Length Repartition");  displayRepartition(f, M_CallLengthRepartition, M_SizeOfCallLengthRepartition);  //  DISPLAY_VAL ("NbCall Average RT(P)",  //                 M_counters[CPT_PD_NbOfCallUsedForAverageResponseTime]);  //  DISPLAY_VAL ("NbCall Average RT",  //                 M_counters[CPT_C_NbOfCallUsedForAverageResponseTime]);  //  DISPLAY_VAL ("NbCall Average CL",  //                 M_counters[CPT_C_NbOfCallUsedForAverageCallLength]);  //  DISPLAY_VAL ("NbCall Average CL(P)",  //                 M_counters[CPT_PD_NbOfCallUsedForAverageCallLength]);  DISPLAY_DLINE ();} /* end of displayData () */void CStat::displayStat (FILE *f){  char   buf1 [64], buf2 [64], buf3 [64];  long   localElapsedTime, globalElapsedTime ;  struct timeval currentTime;  float  averageCallRate;  float  realInstantCallRate;  unsigned long numberOfCall;  GET_TIME (&currentTime);  // computing the real call rate  globalElapsedTime   = computeDiffTimeInMs (&currentTime, &M_startTime);  localElapsedTime    = computeDiffTimeInMs (&currentTime, &M_pdStartTime);  // the call rate is for all the call : incoming and outgoing  numberOfCall        = (M_counters[CPT_C_IncomingCallCreated] +                          M_counters[CPT_C_OutgoingCallCreated]);  averageCallRate     = (globalElapsedTime > 0 ?                          1000*(float)numberOfCall/(float)globalElapsedTime :                         0.0);  numberOfCall        = (M_counters[CPT_PD_IncomingCallCreated] +                          M_counters[CPT_PD_OutgoingCallCreated]);  realInstantCallRate = (localElapsedTime  > 0 ?                          1000*(float)numberOfCall / (float)localElapsedTime :                         0.0);  // build and display header info  DISPLAY_TXT ("Start Time  ", formatTime(&M_startTime));  DISPLAY_TXT ("Last Reset Time", formatTime(&M_pdStartTime));  DISPLAY_TXT ("Current Time", formatTime(&currentTime));  // printing the header in the middle  DISPLAY_CROSS_LINE();  DISPLAY_HEADER();  DISPLAY_CROSS_LINE();  DISPLAY_TXT_COL ("Elapsed Time",                    msToHHMMSSmmm(localElapsedTime),                      msToHHMMSSmmm(globalElapsedTime));  DISPLAY_VAL_RATEF_COL ("Call Rate",  realInstantCallRate, averageCallRate);  DISPLAY_CROSS_LINE ();  DISPLAY_2VAL  ("Incoming call created",                  M_counters[CPT_PD_IncomingCallCreated],                 M_counters[CPT_C_IncomingCallCreated]);  DISPLAY_2VAL  ("OutGoing call created",                  M_counters[CPT_PD_OutgoingCallCreated],                 M_counters[CPT_C_OutgoingCallCreated]);  DISPLAY_CUMUL ("Total Call created", M_counters[CPT_C_IncomingCallCreated] +                 M_counters[CPT_C_OutgoingCallCreated]);  DISPLAY_PERIO ("Current Call",                 M_counters[CPT_C_CurrentCall]);  bool first = true;  for (int i = 0; i < MAX_COUNTER; i++) {    char s[20];    if (M_counters[CPT_C_Generic + i] == 0) {      continue;    }    if (first) {      DISPLAY_CROSS_LINE ();      first = false;    }    sprintf(s, "Generic counter %d", i + 1);    DISPLAY_2VAL(s, M_counters[CPT_PD_Generic + i], M_counters[CPT_C_Generic + i]);  }  DISPLAY_CROSS_LINE ();  DISPLAY_2VAL  ("Successful call",                 M_counters[CPT_PD_SuccessfulCall],                  M_counters[CPT_C_SuccessfulCall]);  DISPLAY_2VAL  ("Failed call",                 M_counters[CPT_PD_FailedCall],                 M_counters[CPT_C_FailedCall]);  //DISPLAY_2VAL  ("Unexpected msg",     //               M_counters[CPT_PD_UnexpectedMessage],   //               M_counters[CPT_C_UnexpectedMessage]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -