00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "C_GeneratorStats.hpp"
00021 #include "GeneratorTrace.hpp"
00022 #include "GeneratorError.h"
00023 #include "StatMacros.hpp"
00024 #include "Utils.hpp"
00025
00026 #include <cstdlib>
00027 #include <cstdio>
00028 #include <cstring>
00029 #include <ctime>
00030
00031 #include "iostream_t.hpp"
00032
00033
00034 C_GeneratorStats* C_GeneratorStats::instance()
00035 {
00036 if (m_instance == NULL) {
00037 NEW_VAR(m_instance, C_GeneratorStats()) ;
00038 }
00039 return m_instance;
00040 }
00041
00042
00043 void C_GeneratorStats::close ()
00044 {
00045
00046 FREE_TABLE(m_ResponseTimeRepartition);
00047
00048 FREE_TABLE(m_CallLengthRepartition) ;
00049
00050 if(m_outputStream != NULL)
00051 {
00052 m_outputStream->close();
00053 DELETE_VAR(m_outputStream);
00054 }
00055
00056 FREE_TABLE(m_fileName);
00057
00058 FREE_TABLE(m_current_repartition_table);
00059
00060
00061 m_SizeOfResponseTimeRepartition = 0;
00062 m_SizeOfCallLengthRepartition = 0;
00063 m_CallLengthRepartition = NULL;
00064 m_fileName = NULL;
00065 m_ResponseTimeRepartition = NULL;
00066 m_outputStream = NULL;
00067
00068 DELETE_VAR(m_instance);
00069 m_instance = NULL;
00070
00071 }
00072
00073
00074 int C_GeneratorStats::init ()
00075 {
00076 if (m_initDone == false) {
00077
00078 RESET_COUNTERS(m_counters);
00079 GET_TIME (&m_startTime);
00080 memcpy (&m_pdStartTime, &m_startTime, sizeof (struct timeval));
00081 memcpy (&m_plStartTime, &m_startTime, sizeof (struct timeval));
00082 m_outputStream = NULL;
00083 m_headerAlreadyDisplayed = false;
00084 m_initDone = true ;
00085
00086 m_current_repartition_table = NULL ;
00087 m_current_display_rep_id = 0 ;
00088 m_nb_display_rep_id = 2 ;
00089 ALLOC_TABLE(m_current_repartition_table,
00090 T_DisplayRepFct*,
00091 sizeof(T_DisplayRepFct), 2);
00092
00093 m_current_repartition_table[0] = &C_GeneratorStats::displayRepartition_without_percent ;
00094 m_current_repartition_table[1] = &C_GeneratorStats::displayRepartition_with_percent ;
00095 m_current_repartition_display = m_current_repartition_table[0];
00096 }
00097 return(1);
00098 }
00099
00100
00101 int C_GeneratorStats::isWellFormed(char * P_listeStr, int * nombre)
00102 {
00103 char * ptr = P_listeStr;
00104 int sizeOf;
00105 bool isANumber;
00106
00107 (*nombre) = 0;
00108 sizeOf = strlen(P_listeStr);
00109
00110 if(sizeOf > 0)
00111 {
00112
00113 isANumber = false;
00114 for(int i=0; i<=sizeOf; i++)
00115 {
00116 switch(ptr[i])
00117 {
00118 case ',':
00119 if(isANumber == false)
00120 {
00121 return(0);
00122 }
00123 else
00124 {
00125 (*nombre)++;
00126 }
00127 isANumber = false;
00128 break;
00129 case '0':
00130 case '1':
00131 case '2':
00132 case '3':
00133 case '4':
00134 case '5':
00135 case '6':
00136 case '7':
00137 case '8':
00138 case '9':
00139 isANumber = true;
00140 break;
00141 case '\t':
00142 case ' ' :
00143 break;
00144 case '\0':
00145 if(isANumber == false)
00146 {
00147 return(0);
00148 }
00149 else
00150 {
00151 (*nombre)++;
00152 }
00153 break;
00154 default:
00155 return(0);
00156 }
00157 }
00158 }
00159 return(1);
00160 }
00161
00162
00163 int C_GeneratorStats::createIntegerTable(char * P_listeStr, unsigned int ** listeInteger, int * sizeOfList)
00164 {
00165 int nb=0;
00166 char * ptr = P_listeStr;
00167 char * ptr_prev = P_listeStr;
00168 unsigned int current_int;
00169
00170 if(isWellFormed(P_listeStr, sizeOfList) == 1)
00171 {
00172
00173 ALLOC_TABLE(*listeInteger, unsigned int*,
00174 sizeof(unsigned int), *sizeOfList);
00175
00176 while((*ptr) != ('\0'))
00177 {
00178 if((*ptr) == ',')
00179 {
00180 sscanf(ptr_prev, "%u", ¤t_int);
00181 if (nb<(*sizeOfList))
00182 (*listeInteger)[nb] = current_int;
00183 nb++;
00184 ptr_prev = ptr+1;
00185 }
00186 ptr++;
00187 }
00188
00189 sscanf(ptr_prev, "%u", ¤t_int);
00190 if (nb<(*sizeOfList))
00191 (*listeInteger)[nb] = current_int;
00192 nb++;
00193 return(1);
00194 }
00195 return(0);
00196 }
00197
00198
00199 void C_GeneratorStats::setFileName(char * P_name, char * P_extension)
00200 {
00201 int sizeOf, sizeOfExtension;
00202
00203 if(P_name != NULL)
00204 {
00205 sizeOf = strlen(P_name);
00206 if (sizeOf > 0) {
00207 if(P_extension != NULL) {
00208 sizeOfExtension = strlen(P_extension);
00209 if (sizeOfExtension > 0) {
00210 FREE_TABLE(m_fileName);
00211 sizeOf += sizeOfExtension;
00212 ALLOC_TABLE(m_fileName, char*,
00213 sizeof(char), sizeOf+1);
00214 strcpy(m_fileName, P_name);
00215 strcat(m_fileName, P_extension);
00216 } else {
00217 FREE_TABLE(m_fileName);
00218 sizeOf += strlen(DEFAULT_EXTENSION);
00219 ALLOC_TABLE(m_fileName, char*,
00220 sizeof(char), sizeOf+1);
00221 strcpy(m_fileName, P_name);
00222 strcat(m_fileName, DEFAULT_EXTENSION);
00223 }
00224 } else {
00225 FREE_TABLE(m_fileName);
00226 sizeOf += strlen(DEFAULT_EXTENSION);
00227 ALLOC_TABLE(m_fileName, char*,
00228 sizeof(char), sizeOf+1);
00229 strcpy(m_fileName, P_name);
00230 strcat(m_fileName, DEFAULT_EXTENSION);
00231 }
00232 } else {
00233 iostream_error << "new file name length is null - keeping the default filename : "
00234 << DEFAULT_FILE_NAME << iostream_endl;
00235 }
00236 } else {
00237 iostream_error << "new file name is NULL ! - keeping the default filename : "
00238 << DEFAULT_FILE_NAME << iostream_endl;
00239 }
00240 }
00241
00242
00243 void C_GeneratorStats::setFileName(char * P_name)
00244 {
00245 int sizeOf;
00246
00247
00248 if(P_name != NULL) {
00249 sizeOf = strlen(P_name);
00250 if(sizeOf > 0) {
00251 FREE_TABLE(m_fileName);
00252 ALLOC_TABLE(m_fileName, char*,
00253 sizeof(char), sizeOf+1);
00254 strcpy(m_fileName, P_name);
00255 } else {
00256 iostream_error << "new file name length is null - keeping the default filename : "
00257 << DEFAULT_FILE_NAME << iostream_endl;
00258 }
00259 } else {
00260 iostream_error <<
00261 "new file name is NULL ! - keeping the default filename : "
00262 << DEFAULT_FILE_NAME << iostream_endl;
00263 }
00264 }
00265
00266
00267
00268 void C_GeneratorStats::setRepartitionCallLength(char * P_listeStr)
00269 {
00270 unsigned int * listeInteger;
00271 int sizeOfListe;
00272
00273 if(createIntegerTable(P_listeStr, &listeInteger, &sizeOfListe) == 1)
00274 initRepartition(listeInteger, sizeOfListe, &m_CallLengthRepartition, &m_SizeOfCallLengthRepartition);
00275 else
00276 {
00277 m_CallLengthRepartition = NULL;
00278 m_SizeOfCallLengthRepartition = 0;
00279 }
00280 FREE_TABLE(listeInteger);
00281 }
00282
00283 void C_GeneratorStats::setRepartitionResponseTime (char * P_listeStr)
00284 {
00285 unsigned int * listeInteger;
00286 int sizeOfListe;
00287
00288 if(createIntegerTable(P_listeStr, &listeInteger, &sizeOfListe) == 1)
00289 initRepartition(listeInteger, sizeOfListe, &m_ResponseTimeRepartition, &m_SizeOfResponseTimeRepartition);
00290 else
00291 {
00292 m_CallLengthRepartition = NULL;
00293 m_SizeOfCallLengthRepartition = 0;
00294 }
00295 FREE_TABLE(listeInteger);
00296 }
00297
00298
00299 void C_GeneratorStats::setRepartitionCallLength(unsigned int* repartition, int nombre)
00300 {
00301 initRepartition(repartition,
00302 nombre,
00303 &m_CallLengthRepartition,
00304 &m_SizeOfCallLengthRepartition);
00305 }
00306
00307 void C_GeneratorStats::setRepartitionResponseTime(unsigned int* repartition, int nombre)
00308 {
00309 initRepartition(repartition,
00310 nombre,
00311 &m_ResponseTimeRepartition,
00312 &m_SizeOfResponseTimeRepartition);
00313 }
00314
00315
00316 void C_GeneratorStats::initRepartition(unsigned int* repartition,
00317 int nombre,
00318 T_dynamicalRepartition ** tabRepartition,
00319 int* tabNb)
00320 {
00321 bool sortDone;
00322 int i;
00323 unsigned int swap;
00324
00325 if((nombre <= 0) || (repartition == NULL) )
00326 {
00327 (*tabNb) = 0;
00328 (*tabRepartition) = NULL;
00329 return;
00330 }
00331
00332 (*tabNb) = nombre + 1;
00333 ALLOC_TABLE(*tabRepartition, T_dynamicalRepartition*,
00334 sizeof(T_dynamicalRepartition), *tabNb);
00335
00336
00337 for(i=0; i<nombre; i++)
00338 {
00339 (*tabRepartition)[i].borderMax = repartition[i];
00340 (*tabRepartition)[i].nbInThisBorder = 0;
00341 }
00342
00343
00344 sortDone = false;
00345 while(!sortDone)
00346 {
00347 sortDone = true;
00348 for(i=0; i<(nombre-1); i++)
00349 {
00350 if((*tabRepartition)[i].borderMax > (*tabRepartition)[i+1].borderMax)
00351 {
00352
00353 swap = (*tabRepartition)[i].borderMax;
00354 (*tabRepartition)[i].borderMax = (*tabRepartition)[i+1].borderMax;
00355 (*tabRepartition)[i+1].borderMax = swap;
00356 sortDone = false;
00357 }
00358 }
00359 }
00360
00361 (*tabRepartition)[nombre].borderMax
00362 = (*tabRepartition)[nombre-1].borderMax;
00363 (*tabRepartition)[nombre].nbInThisBorder = 0;
00364 }
00365
00366
00367 int C_GeneratorStats::computeStat (E_Action P_action)
00368 {
00369 switch (P_action) {
00370
00371 case E_CREATE_INCOMING_CALL :
00372
00373 m_mutexTable[CPT_C_IncomingCallCreated].lock() ;
00374 m_counters [CPT_C_IncomingCallCreated]++;
00375 m_counters [CPT_PD_IncomingCallCreated]++;
00376 m_counters [CPT_PL_IncomingCallCreated]++;
00377 m_mutexTable[CPT_C_IncomingCallCreated].unlock() ;
00378
00379 m_mutexTable[CPT_C_CurrentCall].lock();
00380 m_counters [CPT_C_CurrentCall]++;
00381 m_mutexTable[CPT_C_CurrentCall].unlock();
00382 break;
00383
00384 case E_SEND_MSG :
00385 m_mutexTable[CPT_C_MsgSend].lock() ;
00386 m_counters [CPT_C_MsgSend]++;
00387 m_counters [CPT_PD_MsgSend]++;
00388 m_counters [CPT_PL_MsgSend]++;
00389 m_mutexTable[CPT_C_MsgSend].unlock() ;
00390 break;
00391
00392 case E_RECV_MSG :
00393 m_mutexTable[CPT_C_MsgRecv].lock() ;
00394 m_counters [CPT_C_MsgRecv]++;
00395 m_counters [CPT_PD_MsgRecv]++;
00396 m_counters [CPT_PL_MsgRecv]++;
00397 m_mutexTable[CPT_C_MsgRecv].unlock() ;
00398 break;
00399
00400 case E_CALL_FAILED :
00401 m_mutexTable[CPT_C_FailedCall].lock() ;
00402 m_counters [CPT_C_FailedCall]++;
00403 m_counters [CPT_PD_FailedCall]++;
00404 m_counters [CPT_PL_FailedCall]++;
00405 m_mutexTable[CPT_C_FailedCall].unlock() ;
00406 m_mutexTable[CPT_C_CurrentCall].lock();
00407 m_counters [CPT_C_CurrentCall]--;
00408 m_mutexTable[CPT_C_CurrentCall].unlock();
00409 break;
00410
00411 case E_CALL_INIT_SUCCESSFULLY_ENDED :
00412 m_mutexTable[CPT_C_InitSuccessfulCall].lock() ;
00413 m_counters [CPT_C_InitSuccessfulCall]++;
00414 m_counters [CPT_PD_InitSuccessfulCall]++;
00415 m_counters [CPT_PL_InitSuccessfulCall]++;
00416 m_mutexTable[CPT_C_InitSuccessfulCall].unlock() ;
00417
00418 m_mutexTable[CPT_C_CurrentCall].lock();
00419 m_counters [CPT_C_CurrentCall]--;
00420 m_mutexTable[CPT_C_CurrentCall].unlock();
00421 break;
00422
00423 case E_CALL_TRAFFIC_SUCCESSFULLY_ENDED :
00424 m_mutexTable[CPT_C_TrafficSuccessfulCall].lock() ;
00425 m_counters [CPT_C_TrafficSuccessfulCall]++;
00426 m_counters [CPT_PD_TrafficSuccessfulCall]++;
00427 m_counters [CPT_PL_TrafficSuccessfulCall]++;
00428 m_mutexTable[CPT_C_TrafficSuccessfulCall].unlock() ;
00429
00430 m_mutexTable[CPT_C_CurrentCall].lock();
00431 m_counters [CPT_C_CurrentCall]--;
00432 m_mutexTable[CPT_C_CurrentCall].unlock();
00433 break;
00434
00435 case E_CALL_DEFAULT_SUCCESSFULLY_ENDED :
00436 m_mutexTable[CPT_C_DefaultSuccessfulCall].lock() ;
00437 m_counters [CPT_C_DefaultSuccessfulCall]++;
00438 m_counters [CPT_PD_DefaultSuccessfulCall]++;
00439 m_counters [CPT_PL_DefaultSuccessfulCall]++;
00440 m_mutexTable[CPT_C_DefaultSuccessfulCall].unlock() ;
00441
00442 m_mutexTable[CPT_C_CurrentCall].lock();
00443 m_counters [CPT_C_CurrentCall]--;
00444 m_mutexTable[CPT_C_CurrentCall].unlock();
00445 break;
00446
00447 case E_CALL_ABORT_SUCCESSFULLY_ENDED :
00448 m_mutexTable[CPT_C_AbortSuccessfulCall].lock() ;
00449 m_counters [CPT_C_AbortSuccessfulCall]++;
00450 m_counters [CPT_PD_AbortSuccessfulCall]++;
00451 m_counters [CPT_PL_AbortSuccessfulCall]++;
00452 m_mutexTable[CPT_C_AbortSuccessfulCall].unlock() ;
00453
00454 m_mutexTable[CPT_C_CurrentCall].lock();
00455 m_counters [CPT_C_CurrentCall]--;
00456 m_mutexTable[CPT_C_CurrentCall].unlock();
00457 break;
00458
00459 case E_FAILED_CANNOT_SEND_MSG :
00460 m_mutexTable[CPT_C_FailedCallCannotSendMessage].lock() ;
00461 m_counters [CPT_C_FailedCallCannotSendMessage]++;
00462 m_counters [CPT_PD_FailedCallCannotSendMessage]++;
00463 m_counters [CPT_PL_FailedCallCannotSendMessage]++;
00464 m_mutexTable[CPT_C_FailedCallCannotSendMessage].unlock() ;
00465 break;
00466
00467 case E_FAILED_UNEXPECTED_MSG :
00468 m_mutexTable[CPT_C_FailedCallUnexpectedMessage].lock() ;
00469 m_counters [CPT_C_FailedCallUnexpectedMessage]++;
00470 m_counters [CPT_PD_FailedCallUnexpectedMessage]++;
00471 m_counters [CPT_PL_FailedCallUnexpectedMessage]++;
00472 m_mutexTable[CPT_C_FailedCallUnexpectedMessage].unlock() ;
00473 break;
00474
00475 case E_RESET_PD_COUNTERS :
00476 m_mutexTable[CPT_PD_IncomingCallCreated].lock();
00477 m_counters[CPT_PD_IncomingCallCreated] = (unsigned long) 0;
00478 m_counters[CPT_PD_OutgoingCallCreated] = (unsigned long) 0;
00479 m_counters[CPT_PD_MsgRecv] = (unsigned long) 0;
00480 m_counters[CPT_PD_MsgSend] = (unsigned long) 0;
00481
00482 m_counters[CPT_PD_InitSuccessfulCall] = (unsigned long) 0;
00483 m_counters[CPT_PD_TrafficSuccessfulCall] = (unsigned long) 0;
00484 m_counters[CPT_PD_DefaultSuccessfulCall] = (unsigned long) 0;
00485 m_counters[CPT_PD_AbortSuccessfulCall] = (unsigned long) 0;
00486
00487 m_counters[CPT_PD_FailedCall] = (unsigned long) 0;
00488
00489 GET_TIME (&m_pdStartTime);
00490 m_mutexTable[CPT_PD_IncomingCallCreated].unlock();
00491 break;
00492
00493 case E_RESET_PL_COUNTERS :
00494 RESET_PL_COUNTERS (m_counters);
00495 GET_TIME (&m_plStartTime);
00496 break;
00497
00498 case E_CREATE_OUTGOING_CALL :
00499
00500 m_mutexTable [CPT_C_OutgoingCallCreated].lock() ;
00501 m_counters [CPT_C_OutgoingCallCreated]++;
00502 m_counters [CPT_PD_OutgoingCallCreated]++;
00503 m_counters [CPT_PL_OutgoingCallCreated]++;
00504 m_mutexTable [CPT_C_OutgoingCallCreated].unlock() ;
00505
00506 m_mutexTable [CPT_C_CurrentCall].lock() ;
00507 m_counters [CPT_C_CurrentCall]++;
00508 m_mutexTable [CPT_C_CurrentCall].unlock() ;
00509 break;
00510
00511
00512
00513 case E_FAILED_MAX_UDP_RETRANS :
00514 m_counters [CPT_C_FailedCallMaxUdpRetrans]++;
00515 m_counters [CPT_PD_FailedCallMaxUdpRetrans]++;
00516 m_counters [CPT_PL_FailedCallMaxUdpRetrans]++;
00517 break;
00518
00519 case E_FAILED_CALL_REJECTED :
00520 m_counters [CPT_C_FailedCallCallRejected]++;
00521 m_counters [CPT_PD_FailedCallCallRejected]++;
00522 m_counters [CPT_PL_FailedCallCallRejected]++;
00523 break;
00524
00525 case E_FAILED_CMD_NOT_SENT :
00526 m_counters [CPT_C_FailedCallCmdNotSent]++;
00527 m_counters [CPT_PD_FailedCallCmdNotSent]++;
00528 m_counters [CPT_PL_FailedCallCmdNotSent]++;
00529 break;
00530
00531 case E_FAILED_REGEXP_DOESNT_MATCH :
00532 m_counters [CPT_C_FailedCallRegexpDoesntMatch]++;
00533 m_counters [CPT_PD_FailedCallRegexpDoesntMatch]++;
00534 m_counters [CPT_PL_FailedCallRegexpDoesntMatch]++;
00535 break;
00536
00537 case E_FAILED_REGEXP_HDR_NOT_FOUND :
00538 m_counters [CPT_C_FailedCallRegexpHdrNotFound]++;
00539 m_counters [CPT_PD_FailedCallRegexpHdrNotFound]++;
00540 m_counters [CPT_PL_FailedCallRegexpHdrNotFound]++;
00541 break;
00542
00543
00544 default :
00545 GEN_FATAL(0,"C_GeneratorStats::ComputeStat() - Unrecognized Action " << P_action);
00546 break ;
00547 }
00548
00549 return (0);
00550 }
00551
00552
00553
00554 int C_GeneratorStats::executeStatAction (E_Action P_action) {
00555
00556 switch (P_action) {
00557
00558 case E_CREATE_INCOMING_CALL :
00559
00560 m_mutexTable[CPT_C_IncomingCallCreated].lock() ;
00561 m_counters [CPT_C_IncomingCallCreated]++;
00562 m_counters [CPT_PD_IncomingCallCreated]++;
00563 m_counters [CPT_PL_IncomingCallCreated]++;
00564 m_mutexTable[CPT_C_IncomingCallCreated].unlock() ;
00565
00566 m_mutexTable[CPT_C_CurrentCall].lock();
00567 m_counters [CPT_C_CurrentCall]++;
00568 m_mutexTable[CPT_C_CurrentCall].unlock();
00569 break;
00570
00571 case E_SEND_MSG :
00572 m_mutexTable[CPT_C_MsgSend].lock() ;
00573 m_counters [CPT_C_MsgSend]++;
00574 m_counters [CPT_PD_MsgSend]++;
00575 m_counters [CPT_PL_MsgSend]++;
00576 m_mutexTable[CPT_C_MsgSend].unlock() ;
00577 break;
00578
00579 case E_RECV_MSG :
00580 m_mutexTable[CPT_C_MsgRecv].lock() ;
00581 m_counters [CPT_C_MsgRecv]++;
00582 m_counters [CPT_PD_MsgRecv]++;
00583 m_counters [CPT_PL_MsgRecv]++;
00584 m_mutexTable[CPT_C_MsgRecv].unlock() ;
00585 break;
00586
00587 case E_CALL_FAILED :
00588 m_mutexTable[CPT_C_FailedCall].lock() ;
00589 m_counters [CPT_C_FailedCall]++;
00590 m_counters [CPT_PD_FailedCall]++;
00591 m_counters [CPT_PL_FailedCall]++;
00592 m_mutexTable[CPT_C_FailedCall].unlock() ;
00593
00594 m_mutexTable[CPT_C_CurrentCall].lock();
00595 m_counters [CPT_C_CurrentCall]--;
00596 m_mutexTable[CPT_C_CurrentCall].unlock();
00597 break;
00598
00599 case E_CALL_INIT_SUCCESSFULLY_ENDED :
00600 m_mutexTable[CPT_C_InitSuccessfulCall].lock() ;
00601 m_counters [CPT_C_InitSuccessfulCall]++;
00602 m_counters [CPT_PD_InitSuccessfulCall]++;
00603 m_counters [CPT_PL_InitSuccessfulCall]++;
00604 m_mutexTable[CPT_C_InitSuccessfulCall].unlock() ;
00605
00606 m_mutexTable[CPT_C_CurrentCall].lock();
00607 m_counters [CPT_C_CurrentCall]--;
00608 m_mutexTable[CPT_C_CurrentCall].unlock();
00609 break;
00610
00611 case E_CALL_TRAFFIC_SUCCESSFULLY_ENDED :
00612 m_mutexTable[CPT_C_TrafficSuccessfulCall].lock() ;
00613 m_counters [CPT_C_TrafficSuccessfulCall]++;
00614 m_counters [CPT_PD_TrafficSuccessfulCall]++;
00615 m_counters [CPT_PL_TrafficSuccessfulCall]++;
00616 m_mutexTable[CPT_C_TrafficSuccessfulCall].unlock() ;
00617
00618 m_mutexTable[CPT_C_CurrentCall].lock();
00619 m_counters [CPT_C_CurrentCall]--;
00620 m_mutexTable[CPT_C_CurrentCall].unlock();
00621 break;
00622
00623 case E_CALL_DEFAULT_SUCCESSFULLY_ENDED :
00624 m_mutexTable[CPT_C_DefaultSuccessfulCall].lock() ;
00625 m_counters [CPT_C_DefaultSuccessfulCall]++;
00626 m_counters [CPT_PD_DefaultSuccessfulCall]++;
00627 m_counters [CPT_PL_DefaultSuccessfulCall]++;
00628 m_mutexTable[CPT_C_DefaultSuccessfulCall].unlock() ;
00629
00630 m_mutexTable[CPT_C_CurrentCall].lock();
00631 m_counters [CPT_C_CurrentCall]--;
00632 m_mutexTable[CPT_C_CurrentCall].unlock();
00633 break;
00634
00635 case E_CALL_ABORT_SUCCESSFULLY_ENDED :
00636 m_mutexTable[CPT_C_AbortSuccessfulCall].lock() ;
00637 m_counters [CPT_C_AbortSuccessfulCall]++;
00638 m_counters [CPT_PD_AbortSuccessfulCall]++;
00639 m_counters [CPT_PL_AbortSuccessfulCall]++;
00640 m_mutexTable[CPT_C_AbortSuccessfulCall].unlock() ;
00641
00642 m_mutexTable[CPT_C_CurrentCall].lock();
00643 m_counters [CPT_C_CurrentCall]--;
00644 m_mutexTable[CPT_C_CurrentCall].unlock();
00645 break;
00646
00647 case E_FAILED_CANNOT_SEND_MSG :
00648 m_mutexTable[CPT_C_FailedCallCannotSendMessage].lock() ;
00649 m_counters [CPT_C_FailedCallCannotSendMessage]++;
00650 m_counters [CPT_PD_FailedCallCannotSendMessage]++;
00651 m_counters [CPT_PL_FailedCallCannotSendMessage]++;
00652 m_mutexTable[CPT_C_FailedCallCannotSendMessage].unlock() ;
00653 break;
00654
00655 case E_FAILED_UNEXPECTED_MSG :
00656 m_mutexTable [CPT_C_FailedCallUnexpectedMessage].lock() ;
00657 m_counters [CPT_C_FailedCallUnexpectedMessage]++;
00658 m_counters [CPT_PD_FailedCallUnexpectedMessage]++;
00659 m_counters [CPT_PL_FailedCallUnexpectedMessage]++;
00660 m_mutexTable [CPT_C_FailedCallUnexpectedMessage].unlock() ;
00661 break;
00662
00663 case E_CALL_REFUSED :
00664 m_mutexTable[CPT_C_RefusedCall].lock() ;
00665 m_counters [CPT_C_RefusedCall]++;
00666 m_counters [CPT_PD_RefusedCall]++;
00667 m_counters [CPT_PL_RefusedCall]++;
00668 m_mutexTable[CPT_C_RefusedCall].unlock() ;
00669 break;
00670
00671
00672 case E_FAILED_ABORTED:
00673 m_mutexTable[CPT_C_FailedCallAborted].lock() ;
00674 m_counters [CPT_C_FailedCallAborted] ++ ;
00675 m_counters [CPT_PD_FailedCallAborted] ++ ;
00676 m_counters [CPT_PL_FailedCallAborted] ++ ;
00677 m_mutexTable[CPT_C_FailedCallAborted].unlock() ;
00678 break ;
00679
00680 case E_FAILED_TIMEOUT:
00681 m_mutexTable[CPT_C_FailedCallTimeout].lock() ;
00682 m_counters [CPT_C_FailedCallTimeout] ++ ;
00683 m_counters [CPT_PL_FailedCallTimeout] ++ ;
00684 m_counters [CPT_PD_FailedCallTimeout] ++ ;
00685 m_mutexTable[CPT_C_FailedCallTimeout].unlock() ;
00686 break ;
00687
00688
00689 case E_RESET_PD_COUNTERS :
00690
00691 m_mutexTable[CPT_C_IncomingCallCreated].lock() ;
00692 m_counters [CPT_PD_IncomingCallCreated] = ZERO_COUNTER_VALUE ;
00693 m_mutexTable[CPT_C_IncomingCallCreated].unlock() ;
00694
00695 m_mutexTable[CPT_C_MsgSend].lock() ;
00696 m_counters [CPT_PD_MsgSend] = ZERO_COUNTER_VALUE ;
00697 m_mutexTable[CPT_C_MsgSend].unlock() ;
00698
00699 m_mutexTable[CPT_C_MsgRecv].lock() ;
00700 m_counters [CPT_PD_MsgRecv] = ZERO_COUNTER_VALUE ;
00701 m_mutexTable[CPT_C_MsgRecv].unlock() ;
00702
00703 m_mutexTable[CPT_C_FailedCall].lock() ;
00704 m_counters [CPT_PD_FailedCall] = ZERO_COUNTER_VALUE ;
00705 m_mutexTable[CPT_C_FailedCall].unlock() ;
00706
00707 m_mutexTable[CPT_C_InitSuccessfulCall].lock() ;
00708 m_counters [CPT_PD_InitSuccessfulCall] = ZERO_COUNTER_VALUE ;
00709 m_mutexTable[CPT_C_InitSuccessfulCall].unlock() ;
00710
00711 m_mutexTable[CPT_C_TrafficSuccessfulCall].lock() ;
00712 m_counters [CPT_PD_TrafficSuccessfulCall] = ZERO_COUNTER_VALUE ;
00713 m_mutexTable[CPT_C_TrafficSuccessfulCall].unlock() ;
00714
00715 m_mutexTable[CPT_C_AbortSuccessfulCall].lock() ;
00716 m_counters [CPT_PD_AbortSuccessfulCall] = ZERO_COUNTER_VALUE ;
00717 m_mutexTable[CPT_C_AbortSuccessfulCall].unlock() ;
00718
00719 m_mutexTable[CPT_C_DefaultSuccessfulCall].lock() ;
00720 m_counters [CPT_PD_DefaultSuccessfulCall] = ZERO_COUNTER_VALUE ;
00721 m_mutexTable[CPT_C_DefaultSuccessfulCall].unlock() ;
00722
00723 m_mutexTable[CPT_C_FailedCallCannotSendMessage].lock() ;
00724 m_counters [CPT_PD_FailedCallCannotSendMessage] = ZERO_COUNTER_VALUE ;
00725 m_mutexTable[CPT_C_FailedCallCannotSendMessage].unlock() ;
00726
00727 m_mutexTable[CPT_C_FailedCallUnexpectedMessage].lock() ;
00728 m_counters [CPT_PD_FailedCallUnexpectedMessage] = ZERO_COUNTER_VALUE ;
00729 m_mutexTable[CPT_C_FailedCallUnexpectedMessage].unlock() ;
00730
00731 m_mutexTable[CPT_C_RefusedCall].lock() ;
00732 m_counters [CPT_PD_RefusedCall] = ZERO_COUNTER_VALUE ;
00733 m_mutexTable[CPT_C_RefusedCall].unlock() ;
00734
00735 m_mutexTable[CPT_C_FailedCallAborted].lock() ;
00736 m_counters [CPT_PD_FailedCallAborted] = ZERO_COUNTER_VALUE ;
00737 m_mutexTable[CPT_C_FailedCallAborted].unlock() ;
00738
00739 m_mutexTable[CPT_C_OutgoingCallCreated].lock() ;
00740 m_counters [CPT_PD_OutgoingCallCreated] = ZERO_COUNTER_VALUE ;
00741 m_mutexTable[CPT_C_OutgoingCallCreated].unlock() ;
00742
00743 m_mutexTable[CPT_C_FailedCallTimeout].lock() ;
00744 m_counters [CPT_PD_FailedCallTimeout] = ZERO_COUNTER_VALUE ;
00745 m_mutexTable[CPT_C_FailedCallTimeout].unlock() ;
00746
00747
00748 m_mutexTable[CPT_PD_NbOfCallUsedForAverageResponseTime].lock() ;
00749 m_counters [CPT_PD_NbOfCallUsedForAverageResponseTime] = ZERO_COUNTER_VALUE ;
00750 m_mutexTable[CPT_PD_NbOfCallUsedForAverageResponseTime].unlock() ;
00751
00752 m_mutexTable[CPT_PD_AverageResponseTime].lock() ;
00753 m_counters [CPT_PD_AverageResponseTime] = ZERO_COUNTER_VALUE ;
00754 m_mutexTable[CPT_PD_AverageResponseTime].unlock() ;
00755
00756 m_PD_sumResponseTime = 0;
00757
00758
00759 GET_TIME (&m_pdStartTime);
00760 break;
00761
00762 case E_RESET_PL_COUNTERS :
00763
00764 m_mutexTable[CPT_C_IncomingCallCreated].lock() ;
00765 m_counters [CPT_PL_IncomingCallCreated] = ZERO_COUNTER_VALUE ;
00766 m_mutexTable[CPT_C_IncomingCallCreated].unlock() ;
00767
00768 m_mutexTable[CPT_C_MsgSend].lock() ;
00769 m_counters [CPT_PL_MsgSend] = ZERO_COUNTER_VALUE ;
00770 m_mutexTable[CPT_C_MsgSend].unlock() ;
00771
00772 m_mutexTable[CPT_C_MsgRecv].lock() ;
00773 m_counters [CPT_PL_MsgRecv] = ZERO_COUNTER_VALUE ;
00774 m_mutexTable[CPT_C_MsgRecv].unlock() ;
00775
00776 m_mutexTable[CPT_C_FailedCall].lock() ;
00777 m_counters [CPT_PL_FailedCall] = ZERO_COUNTER_VALUE ;
00778 m_mutexTable[CPT_C_FailedCall].unlock() ;
00779
00780 m_mutexTable[CPT_C_InitSuccessfulCall].lock() ;
00781 m_counters [CPT_PL_InitSuccessfulCall] = ZERO_COUNTER_VALUE ;
00782 m_mutexTable[CPT_C_InitSuccessfulCall].unlock() ;
00783
00784 m_mutexTable[CPT_C_TrafficSuccessfulCall].lock() ;
00785 m_counters [CPT_PL_TrafficSuccessfulCall] = ZERO_COUNTER_VALUE ;
00786 m_mutexTable[CPT_C_TrafficSuccessfulCall].unlock() ;
00787
00788 m_mutexTable[CPT_C_AbortSuccessfulCall].lock() ;
00789 m_counters [CPT_PL_AbortSuccessfulCall] = ZERO_COUNTER_VALUE ;
00790 m_mutexTable[CPT_C_AbortSuccessfulCall].unlock() ;
00791
00792 m_mutexTable[CPT_C_DefaultSuccessfulCall].lock() ;
00793 m_counters [CPT_PL_DefaultSuccessfulCall] = ZERO_COUNTER_VALUE ;
00794 m_mutexTable[CPT_C_DefaultSuccessfulCall].unlock() ;
00795
00796 m_mutexTable[CPT_C_FailedCallCannotSendMessage].lock() ;
00797 m_counters [CPT_PL_FailedCallCannotSendMessage] = ZERO_COUNTER_VALUE ;
00798 m_mutexTable[CPT_C_FailedCallCannotSendMessage].unlock() ;
00799
00800 m_mutexTable[CPT_C_FailedCallUnexpectedMessage].lock() ;
00801 m_counters [CPT_PL_FailedCallUnexpectedMessage] = ZERO_COUNTER_VALUE ;
00802 m_mutexTable[CPT_C_FailedCallUnexpectedMessage].unlock() ;
00803
00804 m_mutexTable[CPT_C_RefusedCall].lock() ;
00805 m_counters [CPT_PL_RefusedCall] = ZERO_COUNTER_VALUE ;
00806 m_mutexTable[CPT_C_RefusedCall].unlock() ;
00807
00808 m_mutexTable[CPT_C_FailedCallAborted].lock() ;
00809 m_counters [CPT_PL_FailedCallAborted] = ZERO_COUNTER_VALUE ;
00810 m_mutexTable[CPT_C_FailedCallAborted].unlock() ;
00811
00812 m_mutexTable[CPT_C_OutgoingCallCreated].lock() ;
00813 m_counters [CPT_PL_OutgoingCallCreated] = ZERO_COUNTER_VALUE ;
00814 m_mutexTable[CPT_C_OutgoingCallCreated].unlock() ;
00815
00816 m_mutexTable[CPT_C_FailedCallTimeout].lock() ;
00817 m_counters [CPT_PL_FailedCallTimeout] = ZERO_COUNTER_VALUE ;
00818 m_mutexTable[CPT_C_FailedCallTimeout].unlock() ;
00819
00820
00821 m_mutexTable[CPT_PL_NbOfCallUsedForAverageResponseTime].lock() ;
00822 m_counters [CPT_PL_NbOfCallUsedForAverageResponseTime] = ZERO_COUNTER_VALUE ;
00823 m_mutexTable[CPT_PL_NbOfCallUsedForAverageResponseTime].unlock() ;
00824
00825
00826 m_mutexTable[CPT_PL_AverageResponseTime].lock() ;
00827 m_counters [CPT_PL_AverageResponseTime] = ZERO_COUNTER_VALUE ;
00828 m_mutexTable[CPT_PL_AverageResponseTime].unlock() ;
00829 m_PL_sumResponseTime = 0;
00830
00831
00832 GET_TIME (&m_plStartTime);
00833 break;
00834
00835 case E_CREATE_OUTGOING_CALL :
00836
00837 m_mutexTable[CPT_C_OutgoingCallCreated].lock() ;
00838 m_counters [CPT_C_OutgoingCallCreated]++;
00839 m_counters [CPT_PD_OutgoingCallCreated]++;
00840 m_counters [CPT_PL_OutgoingCallCreated]++;
00841 m_mutexTable[CPT_C_OutgoingCallCreated].unlock() ;
00842
00843 m_mutexTable[CPT_C_CurrentCall].lock();
00844 m_counters [CPT_C_CurrentCall]++;
00845 m_mutexTable[CPT_C_CurrentCall].unlock();
00846 break;
00847
00848
00849 default :
00850 GEN_FATAL(0,"C_GeneratorStats::executeStatAction() - Unrecognized Action " << P_action);
00851 break ;
00852
00853 }
00854
00855 return (0);
00856 }
00857
00858
00859
00860
00861 void C_GeneratorStats::updateAverageCounter(E_CounterName P_AvarageCounter,
00862 E_CounterName P_NbOfCallUsed,
00863 unsigned long long* P_sum,
00864 unsigned long P_value)
00865 {
00866 if (m_counters [P_NbOfCallUsed] <= 0)
00867 {
00868 m_counters [P_NbOfCallUsed] ++;
00869 m_counters [P_AvarageCounter] = P_value;
00870 (*P_sum) = P_value;
00871 }
00872 else
00873 {
00874 (*P_sum) = P_value + (*P_sum);
00875 m_counters [P_AvarageCounter] = (*P_sum) /
00876 (m_counters [P_NbOfCallUsed] + 1);
00877
00878 m_counters [P_NbOfCallUsed] ++;
00879 }
00880 }
00881
00882 int C_GeneratorStats::computeStat (E_Action P_action, unsigned long P_value)
00883 {
00884 switch (P_action)
00885 {
00886 case E_ADD_CALL_DURATION :
00887
00888 updateAverageCounter(CPT_C_AverageCallLength, CPT_C_NbOfCallUsedForAverageCallLength,
00889 &m_C_sumCallLength, P_value);
00890 updateRepartition(m_CallLengthRepartition, m_SizeOfCallLengthRepartition, P_value);
00891
00892 updateAverageCounter(CPT_PD_AverageCallLength, CPT_PD_NbOfCallUsedForAverageCallLength,
00893 &m_PD_sumCallLength, P_value);
00894
00895 updateAverageCounter(CPT_PL_AverageCallLength, CPT_PL_NbOfCallUsedForAverageCallLength,
00896 &m_PL_sumCallLength, P_value);
00897 break;
00898
00899
00900
00901 case E_ADD_RESPONSE_TIME_DURATION :
00902
00903
00904 updateAverageCounter(CPT_C_AverageResponseTime,
00905 CPT_C_NbOfCallUsedForAverageResponseTime,
00906 &m_C_sumResponseTime, P_value);
00907 updateRepartition(m_ResponseTimeRepartition,
00908 m_SizeOfResponseTimeRepartition, P_value);
00909
00910 updateAverageCounter(CPT_PD_AverageResponseTime,
00911 CPT_PD_NbOfCallUsedForAverageResponseTime,
00912 &m_PD_sumResponseTime,
00913 P_value);
00914
00915 updateAverageCounter(CPT_PL_AverageResponseTime,
00916 CPT_PL_NbOfCallUsedForAverageResponseTime,
00917 &m_PL_sumResponseTime,
00918 P_value);
00919 break;
00920
00921 default :
00922 GEN_FATAL(0,"C_GeneratorStats::ComputeStat() - Unrecognized Action " << P_action);
00923 }
00924 return (0);
00925 }
00926
00927
00928 void C_GeneratorStats::updateRepartition( T_dynamicalRepartition* P_tabReport, int P_sizeOfTab, unsigned long P_value)
00929 {
00930 bool found;
00931 int i;
00932
00933 if(P_tabReport != NULL)
00934 {
00935 i = P_sizeOfTab-2;
00936 found = false;
00937 while((found == false) && (i>=1))
00938 {
00939 if( (P_value < P_tabReport[i].borderMax) &&
00940 (P_tabReport[i-1].borderMax <= P_value) )
00941 {
00942 found = true;
00943 P_tabReport[i].nbInThisBorder ++;
00944 }
00945 i--;
00946 }
00947
00948 if(!found)
00949 {
00950 if(P_value < P_tabReport[0].borderMax)
00951 {
00952 P_tabReport[0].nbInThisBorder ++;
00953 }
00954 else if(P_value >= P_tabReport[P_sizeOfTab-1].borderMax)
00955 {
00956 P_tabReport[P_sizeOfTab-1].nbInThisBorder ++;
00957 }
00958 else
00959 {
00960
00961 GEN_ERROR(0,"Unable to sort this Value in the repartition table! " << P_value);
00962 }
00963 }
00964 }
00965 }
00966
00967
00968 C_GeneratorStats::C_GeneratorStats ()
00969 {
00970 size_t L_size = 0;
00971
00972
00973
00974 L_size += strlen(DEFAULT_FILE_NAME) ;
00975 L_size += strlen(DEFAULT_EXTENSION) ;
00976 L_size += 1 ;
00977 ALLOC_TABLE(m_fileName, char*,
00978 sizeof(char), L_size);
00979 strcpy(m_fileName, DEFAULT_FILE_NAME);
00980 strcat(m_fileName, DEFAULT_EXTENSION);
00981 m_ResponseTimeRepartition = NULL;
00982 m_CallLengthRepartition = NULL;
00983 m_SizeOfResponseTimeRepartition = 0;
00984 m_SizeOfCallLengthRepartition = 0;
00985 m_initDone = false ;
00986
00987 m_max_msg_size = 50 ;
00988 ALLOC_TABLE(m_info_msg, char*, sizeof(char), m_max_msg_size+1);
00989 ALLOC_TABLE(m_err_msg, char*, sizeof(char), m_max_msg_size+1);
00990 m_info_msg[0] = '\0' ;
00991 strcpy(m_err_msg, "No error");
00992 }
00993
00994
00995 C_GeneratorStats::~C_GeneratorStats ()
00996 {
00997 m_initDone = false ;
00998 FREE_TABLE(m_info_msg);
00999 FREE_TABLE(m_err_msg);
01000 }
01001
01002 char* C_GeneratorStats::sRepartitionHeader(T_dynamicalRepartition * tabRepartition,
01003 int sizeOfTab,
01004 char * P_repartitionName)
01005 {
01006 static char repartitionHeader[MAX_REPARTITION_HEADER_LENGTH];
01007 char buffer[MAX_CHAR_BUFFER_SIZE];
01008
01009 if(tabRepartition != NULL)
01010 {
01011 sprintf(repartitionHeader, "%s;", P_repartitionName);
01012 for(int i=0; i<(sizeOfTab-1); i++) {
01013 sprintf(buffer, "<%d;", tabRepartition[i].borderMax);
01014 strcat(repartitionHeader, buffer);
01015 }
01016 sprintf(buffer, ">=%d;", tabRepartition[sizeOfTab-1].borderMax);
01017 strcat(repartitionHeader, buffer);
01018 } else {
01019 sprintf(repartitionHeader, "%s", "");
01020 }
01021
01022 return(repartitionHeader);
01023 }
01024
01025 char* C_GeneratorStats::sRepartitionInfo(T_dynamicalRepartition * tabRepartition,
01026 int sizeOfTab)
01027 {
01028 static char repartitionInfo[MAX_REPARTITION_INFO_LENGTH];
01029 char buffer[MAX_CHAR_BUFFER_SIZE];
01030
01031 if(tabRepartition != NULL)
01032 {
01033
01034 sprintf(repartitionInfo, ";");
01035 for(int i=0; i<(sizeOfTab-1); i++)
01036 {
01037 sprintf(buffer, "%ld;", tabRepartition[i].nbInThisBorder);
01038 strcat(repartitionInfo, buffer);
01039 }
01040 sprintf(buffer, "%ld;", tabRepartition[sizeOfTab-1].nbInThisBorder);
01041 strcat(repartitionInfo, buffer);
01042 }
01043 else
01044 {
01045 sprintf(repartitionInfo, "%s", "");
01046 }
01047
01048 return(repartitionInfo);
01049 }
01050
01051
01052 void C_GeneratorStats::displayRepartition_with_percent(T_dynamicalRepartition * tabRepartition,
01053 int sizeOfTab)
01054 {
01055
01056 int L_total_nb_border = 0 ;
01057 int L_i ;
01058 float L_percent_traffic ;
01059
01060
01061 if(tabRepartition != NULL) {
01062 L_total_nb_border = 0 ;
01063 for(L_i = 0 ; L_i < sizeOfTab ; L_i++) {
01064 L_total_nb_border += tabRepartition[L_i].nbInThisBorder ;
01065 }
01066
01067
01068 L_percent_traffic = (L_total_nb_border > 0 ?
01069 (100.0*tabRepartition[0].nbInThisBorder)/ (float)L_total_nb_border :
01070 0.0);
01071
01072 DISPLAY_REPART_F (0,
01073 tabRepartition[0].borderMax,
01074 tabRepartition[0].nbInThisBorder,
01075 L_percent_traffic);
01076
01077 for(L_i = 1 ; L_i < (sizeOfTab-1); L_i++) {
01078
01079 L_percent_traffic = (L_total_nb_border > 0 ?
01080 (100.0*tabRepartition[L_i].nbInThisBorder)/ (float)L_total_nb_border :
01081 0.0);
01082
01083 DISPLAY_REPART_F (tabRepartition[L_i-1].borderMax,
01084 tabRepartition[L_i].borderMax,
01085 tabRepartition[L_i].nbInThisBorder,
01086 L_percent_traffic);
01087 }
01088
01089 L_percent_traffic = (L_total_nb_border > 0 ?
01090 (100.0*tabRepartition[sizeOfTab-1].nbInThisBorder)/ (float)L_total_nb_border :
01091 0.0);
01092
01093
01094 DISPLAY_LAST_REPART_F (tabRepartition[sizeOfTab-1].borderMax,
01095 tabRepartition[sizeOfTab-1].nbInThisBorder,
01096 L_percent_traffic);
01097 }
01098 else
01099 {
01100 DISPLAY_INFO (" <No repartion defined>");
01101 }
01102 }
01103
01104
01105 void C_GeneratorStats::displayRepartition(T_dynamicalRepartition * tabRepartition,
01106 int sizeOfTab)
01107 {
01108 int L_i ;
01109
01110 if(tabRepartition != NULL) {
01111
01112 DISPLAY_REPART (0,
01113 tabRepartition[0].borderMax,
01114 tabRepartition[0].nbInThisBorder);
01115
01116
01117 for(L_i = 1 ; L_i < (sizeOfTab-1); L_i++) {
01118
01119
01120 DISPLAY_REPART (tabRepartition[L_i-1].borderMax,
01121 tabRepartition[L_i].borderMax,
01122 tabRepartition[L_i].nbInThisBorder);
01123 }
01124
01125
01126 DISPLAY_LAST_REPART (tabRepartition[sizeOfTab-1].borderMax,
01127 tabRepartition[sizeOfTab-1].nbInThisBorder);
01128 }
01129 else
01130 {
01131 DISPLAY_INFO (" <No repartion defined>");
01132 }
01133 }
01134
01135
01136 void C_GeneratorStats::displayRepartition_without_percent(T_dynamicalRepartition * tabRepartition,
01137 int sizeOfTab)
01138 {
01139 int L_i ;
01140
01141 if(tabRepartition != NULL) {
01142
01143 DISPLAY_REPART (0,
01144 tabRepartition[0].borderMax,
01145 tabRepartition[0].nbInThisBorder);
01146
01147
01148 for(L_i = 1 ; L_i < (sizeOfTab-1); L_i++) {
01149
01150
01151 DISPLAY_REPART (tabRepartition[L_i-1].borderMax,
01152 tabRepartition[L_i].borderMax,
01153 tabRepartition[L_i].nbInThisBorder);
01154 }
01155
01156
01157 DISPLAY_LAST_REPART (tabRepartition[sizeOfTab-1].borderMax,
01158 tabRepartition[sizeOfTab-1].nbInThisBorder);
01159 }
01160 else
01161 {
01162 DISPLAY_INFO (" <No repartion defined>");
01163 }
01164 }
01165
01166
01167 void C_GeneratorStats::displayData ()
01168 {
01169 long localElapsedTime, globalElapsedTime ;
01170 struct timeval currentTime;
01171 float averageCallRate;
01172 float realInstantCallRate;
01173 unsigned long numberOfCall;
01174
01175 GET_TIME (¤tTime);
01176
01177 globalElapsedTime = ms_difftime (¤tTime, &m_startTime);
01178 localElapsedTime = ms_difftime (¤tTime, &m_pdStartTime);
01179
01180 numberOfCall = m_counters[CPT_C_IncomingCallCreated] + m_counters[CPT_C_OutgoingCallCreated];
01181 averageCallRate = (globalElapsedTime > 0 ? 1000*(float)numberOfCall/(float)globalElapsedTime : 0.0);
01182 numberOfCall = m_counters[CPT_PD_IncomingCallCreated] + m_counters[CPT_PD_OutgoingCallCreated];
01183 realInstantCallRate = (localElapsedTime > 0 ?
01184 1000*(float)numberOfCall / (float)localElapsedTime :
01185 0.0);
01186
01187
01188 DISPLAY_DLINE ();
01189
01190 DISPLAY_TXT ("Start Time ", formatTime(&m_startTime));
01191 DISPLAY_TXT ("Last Reset Time", formatTime(&m_pdStartTime));
01192 DISPLAY_TXT ("Current Time", formatTime(¤tTime));
01193
01194
01195 DISPLAY_CROSS_LINE();
01196 DISPLAY_HEADER();
01197 DISPLAY_CROSS_LINE();
01198
01199 DISPLAY_TXT_COL ("Elapsed Time", msToHHMMSSmmm(localElapsedTime), msToHHMMSSmmm(globalElapsedTime));
01200
01201 DISPLAY_VAL_RATEF_COL ("Call Rate", realInstantCallRate, averageCallRate);
01202 DISPLAY_CROSS_LINE ();
01203
01204 DISPLAY_2VAL ("Incoming call created", m_counters[CPT_PD_IncomingCallCreated],
01205 m_counters[CPT_C_IncomingCallCreated]);
01206
01207 DISPLAY_2VAL ("OutGoing call created", m_counters[CPT_PD_OutgoingCallCreated],
01208 m_counters[CPT_C_OutgoingCallCreated]);
01209 DISPLAY_CUMUL ("Total Call created", m_counters[CPT_C_IncomingCallCreated] +
01210 m_counters[CPT_C_OutgoingCallCreated]);
01211 DISPLAY_PERIO ("Current Calls", m_counters[CPT_C_CurrentCall]);
01212 DISPLAY_CROSS_LINE ();
01213
01214
01215 DISPLAY_2VAL ("Successful init call", m_counters[CPT_PD_InitSuccessfulCall],
01216 m_counters[CPT_C_InitSuccessfulCall]);
01217
01218 DISPLAY_2VAL ("Successful traffic call", m_counters[CPT_PD_TrafficSuccessfulCall],
01219 m_counters[CPT_C_TrafficSuccessfulCall]);
01220
01221 DISPLAY_2VAL ("Successful default call", m_counters[CPT_PD_DefaultSuccessfulCall],
01222 m_counters[CPT_C_DefaultSuccessfulCall]);
01223
01224 DISPLAY_2VAL ("Successful abort call", m_counters[CPT_PD_AbortSuccessfulCall],
01225 m_counters[CPT_C_AbortSuccessfulCall]);
01226
01227
01228 DISPLAY_2VAL ("Failed call", m_counters[CPT_PD_FailedCall], m_counters[CPT_C_FailedCall]);
01229
01230
01231 DISPLAY_CROSS_LINE ();
01232 DISPLAY_TXT_COL ("Response Time", msToHHMMSSmmm( m_counters [CPT_PD_AverageResponseTime] ),
01233 msToHHMMSSmmm( m_counters [CPT_C_AverageResponseTime] ));
01234 DISPLAY_TXT_COL ("Call Length", msToHHMMSSmmm( m_counters [CPT_PD_AverageCallLength] ),
01235 msToHHMMSSmmm( m_counters [CPT_C_AverageCallLength] ));
01236 DISPLAY_CROSS_LINE ();
01237
01238 DISPLAY_INFO("Average Response Time Repartition");
01239 displayRepartition(m_ResponseTimeRepartition, m_SizeOfResponseTimeRepartition);
01240 DISPLAY_INFO("Average Call Length Repartition");
01241 displayRepartition(m_CallLengthRepartition, m_SizeOfCallLengthRepartition);
01242
01243
01244 DISPLAY_DLINE ();
01245 }
01246
01247
01248 void C_GeneratorStats::displayStat ()
01249 {
01250 long localElapsedTime, globalElapsedTime ;
01251 struct timeval currentTime;
01252
01253 float averageTPS;
01254 float realInstantTPS;
01255 unsigned long numberOfTPS;
01256
01257 GET_TIME (¤tTime);
01258
01259 globalElapsedTime = ms_difftime (¤tTime, &m_startTime);
01260 localElapsedTime = ms_difftime (¤tTime, &m_pdStartTime);
01261
01262 numberOfTPS = m_counters[CPT_C_MsgRecv] + m_counters[CPT_C_MsgSend];
01263
01264 averageTPS = (globalElapsedTime > 0 ? 1000*((float)numberOfTPS/2)/(float)globalElapsedTime : 0.0);
01265
01266 numberOfTPS = m_counters[CPT_PD_MsgRecv] + m_counters[CPT_PD_MsgSend];
01267
01268
01269 realInstantTPS = (localElapsedTime > 0 ?
01270 1000*((float)numberOfTPS) / (float)localElapsedTime :
01271 0.0);
01272
01273
01274
01275 DISPLAY_TXT ("Start Time ", formatTime(&m_startTime));
01276 DISPLAY_TXT ("Last Reset Time", formatTime(&m_pdStartTime));
01277 DISPLAY_TXT ("Current Time", formatTime(¤tTime));
01278
01279
01280 DISPLAY_CROSS_LINE();
01281 DISPLAY_HEADER();
01282 DISPLAY_CROSS_LINE();
01283
01284 DISPLAY_TXT_COL ("Elapsed Time", msToHHMMSSmmm(localElapsedTime), msToHHMMSSmmm(globalElapsedTime));
01285
01286
01287 DISPLAY_VAL_RATEF_TPS ("Call Rate", realInstantTPS, averageTPS);
01288 DISPLAY_CROSS_LINE ();
01289
01290 DISPLAY_2VAL ("Incoming calls",
01291 m_counters[CPT_PD_IncomingCallCreated],
01292 m_counters[CPT_C_IncomingCallCreated]);
01293
01294 DISPLAY_2VAL ("Outgoing calls",
01295 m_counters[CPT_PD_OutgoingCallCreated],
01296 m_counters[CPT_C_OutgoingCallCreated]);
01297
01298
01299 DISPLAY_2VAL ("Message Received", m_counters[CPT_PD_MsgRecv],
01300 m_counters[CPT_C_MsgRecv]);
01301
01302 DISPLAY_2VAL ("Message Send", m_counters[CPT_PD_MsgSend],
01303 m_counters[CPT_C_MsgSend]);
01304
01305
01306 DISPLAY_PERIO ("Current Calls", m_counters[CPT_C_CurrentCall]);
01307 DISPLAY_CROSS_LINE ();
01308
01309 DISPLAY_2VAL ("Successful init call", m_counters[CPT_PD_InitSuccessfulCall],
01310 m_counters[CPT_C_InitSuccessfulCall]);
01311
01312 DISPLAY_2VAL ("Successful traffic call", m_counters[CPT_PD_TrafficSuccessfulCall],
01313 m_counters[CPT_C_TrafficSuccessfulCall]);
01314
01315 DISPLAY_2VAL ("Successful default call", m_counters[CPT_PD_DefaultSuccessfulCall],
01316 m_counters[CPT_C_DefaultSuccessfulCall]);
01317
01318 DISPLAY_2VAL ("Successful abort call", m_counters[CPT_PD_AbortSuccessfulCall],
01319 m_counters[CPT_C_AbortSuccessfulCall]);
01320
01321
01322
01323 DISPLAY_2VAL ("Failed call", m_counters[CPT_PD_FailedCall], m_counters[CPT_C_FailedCall]);
01324
01325 DISPLAY_CROSS_LINE ();
01326
01327 }
01328
01329
01330
01331 void C_GeneratorStats::activate_percent_traffic () {
01332
01333 m_current_display_rep_id ++ ;
01334
01335 if (m_current_display_rep_id == m_nb_display_rep_id) {
01336 m_current_display_rep_id = 0 ;
01337 }
01338 m_current_repartition_display
01339 = m_current_repartition_table[m_current_display_rep_id];
01340
01341 }
01342
01343 void C_GeneratorStats::reset_cumul_counters () {
01344
01345 int L_i ;
01346
01347 for (L_i = C_GeneratorStats::CPT_C_InitSuccessfulCall;
01348 L_i <= C_GeneratorStats::CPT_C_FailedCallTimeout;
01349 L_i++) {
01350 m_mutexTable[L_i].lock();
01351 m_counters[L_i] = (unsigned long) 0;
01352 m_mutexTable[L_i].unlock();
01353 }
01354
01355
01356 if(m_ResponseTimeRepartition != NULL) {
01357 for(L_i=0; L_i < m_SizeOfResponseTimeRepartition; L_i++) {
01358 m_ResponseTimeRepartition[L_i].nbInThisBorder = 0;
01359 }
01360 }
01361
01362 }
01363
01364 void C_GeneratorStats::makeDisplay1 (bool P_display) {
01365
01366 long localElapsedTime ;
01367 long globalElapsedTime ;
01368 struct timeval currentTime ;
01369
01370 float MsgSendPerS;
01371 float MsgRecvPerS;
01372 float AverageMsgRecvPerS;
01373 float AverageMsgSendPerS;
01374 float AverageCurrentCallPerS ;
01375
01376 unsigned long numberOfCall;
01377 float realInstantCallRate ;
01378 float averageCallRate ;
01379
01380 int L_i ;
01381 unsigned long L_PD_successful_call ;
01382 unsigned long L_C_successful_call ;
01383
01384
01385
01386
01387
01388
01389
01390 m_mutexTable[CPT_C_IncomingCallCreated].lock() ;
01391 m_displayCounters[CPT_C_IncomingCallCreated]
01392 = m_counters [CPT_C_IncomingCallCreated];
01393 m_displayCounters[CPT_PD_IncomingCallCreated]
01394 = m_counters [CPT_PD_IncomingCallCreated];
01395 m_mutexTable[CPT_C_IncomingCallCreated].unlock() ;
01396
01397 m_mutexTable[CPT_C_CurrentCall].lock();
01398 m_displayCounters[CPT_C_CurrentCall]
01399 = m_counters [CPT_C_CurrentCall];
01400 m_mutexTable[CPT_C_CurrentCall].unlock();
01401
01402 m_mutexTable[CPT_C_MsgSend].lock() ;
01403 m_displayCounters[CPT_C_MsgSend]
01404 = m_counters [CPT_C_MsgSend];
01405 m_displayCounters[CPT_PD_MsgSend]
01406 = m_counters [CPT_PD_MsgSend];
01407 m_mutexTable[CPT_C_MsgSend].unlock() ;
01408
01409 m_mutexTable[CPT_C_MsgRecv].lock() ;
01410 m_displayCounters[CPT_C_MsgRecv]
01411 = m_counters [CPT_C_MsgRecv];
01412 m_displayCounters[CPT_PD_MsgRecv]
01413 = m_counters [CPT_PD_MsgRecv];
01414 m_mutexTable[CPT_C_MsgRecv].unlock() ;
01415
01416 m_mutexTable[CPT_C_FailedCall].lock() ;
01417 m_displayCounters[CPT_C_FailedCall]
01418 = m_counters [CPT_C_FailedCall];
01419 m_displayCounters[CPT_PD_FailedCall]
01420 = m_counters [CPT_PD_FailedCall];
01421 m_mutexTable[CPT_C_FailedCall].unlock() ;
01422
01423 m_mutexTable[CPT_C_InitSuccessfulCall].lock() ;
01424 m_displayCounters[CPT_C_InitSuccessfulCall]
01425 = m_counters [CPT_C_InitSuccessfulCall];
01426 m_displayCounters[CPT_PD_InitSuccessfulCall]
01427 = m_counters [CPT_PD_InitSuccessfulCall];
01428 m_mutexTable[CPT_C_InitSuccessfulCall].unlock() ;
01429
01430 m_mutexTable[CPT_C_TrafficSuccessfulCall].lock() ;
01431 m_displayCounters[CPT_C_TrafficSuccessfulCall]
01432 = m_counters [CPT_C_TrafficSuccessfulCall];
01433 m_displayCounters[CPT_PD_TrafficSuccessfulCall]
01434 = m_counters [CPT_PD_TrafficSuccessfulCall];
01435 m_mutexTable[CPT_C_TrafficSuccessfulCall].unlock() ;
01436
01437 m_mutexTable[CPT_C_DefaultSuccessfulCall].lock() ;
01438 m_displayCounters[CPT_C_DefaultSuccessfulCall]
01439 = m_counters [CPT_C_DefaultSuccessfulCall];
01440 m_displayCounters[CPT_PD_DefaultSuccessfulCall]
01441 = m_counters [CPT_PD_DefaultSuccessfulCall];
01442 m_mutexTable[CPT_C_DefaultSuccessfulCall].unlock() ;
01443
01444 m_mutexTable[CPT_C_AbortSuccessfulCall].lock() ;
01445 m_displayCounters[CPT_C_AbortSuccessfulCall]
01446 = m_counters [CPT_C_AbortSuccessfulCall];
01447 m_displayCounters[CPT_PD_AbortSuccessfulCall]
01448 = m_counters [CPT_PD_AbortSuccessfulCall];
01449 m_mutexTable[CPT_C_AbortSuccessfulCall].unlock() ;
01450
01451 m_mutexTable[CPT_C_FailedCallCannotSendMessage].lock() ;
01452 m_displayCounters[CPT_C_FailedCallCannotSendMessage]
01453 = m_counters [CPT_C_FailedCallCannotSendMessage];
01454 m_displayCounters[CPT_PD_FailedCallCannotSendMessage]
01455 = m_counters [CPT_PD_FailedCallCannotSendMessage];
01456 m_mutexTable[CPT_C_FailedCallCannotSendMessage].unlock() ;
01457
01458 m_mutexTable[CPT_C_FailedCallUnexpectedMessage].lock() ;
01459 m_displayCounters[CPT_C_FailedCallUnexpectedMessage]
01460 = m_counters [CPT_C_FailedCallUnexpectedMessage];
01461 m_displayCounters[CPT_PD_FailedCallUnexpectedMessage]
01462 = m_counters [CPT_PD_FailedCallUnexpectedMessage];
01463 m_mutexTable[CPT_C_FailedCallUnexpectedMessage].unlock() ;
01464
01465 m_mutexTable[CPT_C_RefusedCall].lock() ;
01466 m_displayCounters[CPT_C_RefusedCall]
01467 = m_counters [CPT_C_RefusedCall];
01468 m_displayCounters[CPT_PD_RefusedCall]
01469 = m_counters [CPT_PD_RefusedCall];
01470 m_mutexTable[CPT_C_RefusedCall].unlock() ;
01471
01472 m_mutexTable[CPT_C_FailedCallAborted].lock() ;
01473 m_displayCounters[CPT_C_FailedCallAborted]
01474 = m_counters [CPT_C_FailedCallAborted];
01475 m_displayCounters[CPT_PD_FailedCallAborted]
01476 = m_counters [CPT_PD_FailedCallAborted];
01477 m_mutexTable[CPT_C_FailedCallAborted].unlock() ;
01478
01479 m_mutexTable[CPT_C_FailedCallTimeout].lock() ;
01480 m_displayCounters[CPT_C_FailedCallTimeout]
01481 = m_counters [CPT_C_FailedCallTimeout];
01482 m_displayCounters[CPT_PD_FailedCallTimeout]
01483 = m_counters [CPT_PD_FailedCallTimeout];
01484 m_mutexTable[CPT_C_FailedCallTimeout].unlock() ;
01485
01486 m_mutexTable[CPT_C_OutgoingCallCreated].lock() ;
01487 m_displayCounters[CPT_C_OutgoingCallCreated]
01488 = m_counters [CPT_C_OutgoingCallCreated];
01489 m_displayCounters[CPT_PD_OutgoingCallCreated]
01490 = m_counters [CPT_PD_OutgoingCallCreated];
01491 m_mutexTable[CPT_C_OutgoingCallCreated].unlock() ;
01492
01493
01494
01495 GET_TIME (¤tTime);
01496
01497 globalElapsedTime = ms_difftime (¤tTime, &m_startTime);
01498 localElapsedTime = ms_difftime (¤tTime, &m_pdStartTime);
01499
01500
01501 numberOfCall
01502 = m_displayCounters[CPT_C_IncomingCallCreated]
01503 + m_displayCounters[CPT_C_OutgoingCallCreated];
01504
01505 averageCallRate
01506 = (globalElapsedTime > 0 ?
01507 1000*(float)numberOfCall/(float)globalElapsedTime : 0.0);
01508
01509 numberOfCall
01510 = m_displayCounters[CPT_PD_IncomingCallCreated]
01511 + m_displayCounters[CPT_PD_OutgoingCallCreated];
01512
01513 realInstantCallRate
01514 = (localElapsedTime > 0 ?
01515 1000*(float)numberOfCall / (float)localElapsedTime :
01516 0.0);
01517
01518 MsgRecvPerS = (localElapsedTime > 0 ?
01519 1000*((float)m_displayCounters[CPT_PD_MsgRecv]) / (float)localElapsedTime :
01520 0.0);
01521
01522 MsgSendPerS = (localElapsedTime > 0 ?
01523 1000*((float)m_displayCounters[CPT_PD_MsgSend]) / (float)localElapsedTime :
01524 0.0);
01525
01526 AverageMsgRecvPerS = (globalElapsedTime > 0 ?
01527 1000*((float)m_displayCounters[CPT_C_MsgRecv]) / (float)globalElapsedTime :
01528 0.0);
01529
01530 AverageMsgSendPerS = (globalElapsedTime > 0 ?
01531 1000*((float)m_displayCounters[CPT_C_MsgSend]) / (float)globalElapsedTime :
01532 0.0);
01533
01534 AverageCurrentCallPerS = (globalElapsedTime > 0 ?
01535 1000*((float)m_displayCounters[CPT_C_CurrentCall]) / (float)globalElapsedTime :
01536 0.0);
01537
01538
01539 L_PD_successful_call =
01540 m_displayCounters[CPT_PD_InitSuccessfulCall] +
01541 m_displayCounters[CPT_PD_TrafficSuccessfulCall] +
01542 m_displayCounters[CPT_PD_DefaultSuccessfulCall] +
01543 m_displayCounters[CPT_PD_AbortSuccessfulCall] ;
01544
01545 L_C_successful_call =
01546 m_displayCounters[CPT_C_InitSuccessfulCall] +
01547 m_displayCounters[CPT_C_TrafficSuccessfulCall] +
01548 m_displayCounters[CPT_C_DefaultSuccessfulCall] +
01549 m_displayCounters[CPT_C_AbortSuccessfulCall] ;
01550
01551
01552
01553
01554 if (P_display) {
01555 DISPLAY_CROSS_LINE ();
01556
01557 {
01558 char L_start_time[TIME_LENGTH];
01559 char L_current_time[TIME_LENGTH];
01560 formatTime(L_start_time, &m_startTime);
01561 formatTime(L_current_time, ¤tTime);
01562 DISPLAY_3TXT ("Start/Current Time",
01563 L_start_time,
01564 L_current_time);
01565 }
01566
01567
01568 DISPLAY_CROSS_LINE();
01569 DISPLAY_HEADER();
01570
01571 DISPLAY_CROSS_LINE();
01572
01573 DISPLAY_TXT_COL ("Elapsed Time", msToHHMMSSmmm(localElapsedTime), msToHHMMSSmmm(globalElapsedTime));
01574
01575 DISPLAY_VAL_RATEF_TPS ("Call rate (/s)", realInstantCallRate, averageCallRate);
01576 DISPLAY_CROSS_LINE ();
01577
01578 DISPLAY_2VAL ("Incoming calls",
01579 m_displayCounters[CPT_PD_IncomingCallCreated],
01580 m_displayCounters[CPT_C_IncomingCallCreated]);
01581
01582 DISPLAY_2VAL ("Outgoing calls",
01583 m_displayCounters[CPT_PD_OutgoingCallCreated],
01584 m_displayCounters[CPT_C_OutgoingCallCreated]);
01585
01586
01587 DISPLAY_2VAL_RATEF ( "Msg Recv/s" ,
01588 MsgRecvPerS,
01589 AverageMsgRecvPerS);
01590
01591 DISPLAY_2VAL_RATEF ( "Msg Sent/s" ,
01592 MsgSendPerS,
01593 AverageMsgSendPerS);
01594
01595 DISPLAY_2VAL ("Unexpected msg",
01596 m_displayCounters[CPT_PD_FailedCallUnexpectedMessage],
01597 m_displayCounters[CPT_C_FailedCallUnexpectedMessage]);
01598
01599 DISPLAY_2VAL_CURRENTF ("Current calls",
01600 m_displayCounters[CPT_C_CurrentCall],
01601 AverageCurrentCallPerS);
01602
01603 DISPLAY_CROSS_LINE ();
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628 DISPLAY_2VAL ("Successful calls",
01629 L_PD_successful_call,
01630 L_C_successful_call);
01631
01632
01633 DISPLAY_2VAL ("Failed calls",
01634 m_displayCounters[CPT_PD_FailedCall],
01635 m_displayCounters[CPT_C_FailedCall]);
01636
01637 DISPLAY_2VAL ("Refused calls",
01638 m_displayCounters[CPT_PD_RefusedCall],
01639 m_displayCounters[CPT_C_RefusedCall]);
01640
01641 DISPLAY_2VAL ("Aborted calls",
01642 m_displayCounters[CPT_PD_FailedCallAborted],
01643 m_displayCounters[CPT_C_FailedCallAborted]);
01644
01645 DISPLAY_2VAL ("Timeout calls",
01646 m_displayCounters[CPT_PD_FailedCallTimeout],
01647 m_displayCounters[CPT_C_FailedCallTimeout]);
01648
01649 DISPLAY_CROSS_LINE ();
01650 DISPLAY_TXT("Last Info", m_info_msg);
01651 DISPLAY_TXT("Last Error", m_err_msg);
01652
01653 printf("|--- Next screen : Press key 1 ----------------------- [h]: Display help ------|\r\n");
01654
01655 } else {
01656 DISPLAY_CROSS_LINE ();
01657
01658
01659
01660
01661
01662 DISPLAY_2VAL ("Success init calls",
01663 m_displayCounters[CPT_PD_InitSuccessfulCall],
01664 m_displayCounters[CPT_C_InitSuccessfulCall]);
01665
01666
01667 DISPLAY_2VAL ("Success traffic calls",
01668 m_displayCounters[CPT_PD_TrafficSuccessfulCall],
01669 m_displayCounters[CPT_C_TrafficSuccessfulCall]);
01670
01671 DISPLAY_2VAL ("Success default calls",
01672 m_displayCounters[CPT_PD_DefaultSuccessfulCall],
01673 m_displayCounters[CPT_C_DefaultSuccessfulCall]);
01674
01675 DISPLAY_2VAL ("Success abort calls",
01676 m_displayCounters[CPT_PD_AbortSuccessfulCall],
01677 m_displayCounters[CPT_C_AbortSuccessfulCall]);
01678
01679
01680
01681 DISPLAY_CROSS_LINE ();
01682
01683 for (L_i = 0 ; L_i < 17 ; L_i ++) {
01684 DISPLAY_INFO((char*)"") ;
01685 }
01686 printf("|--- Next screen : Press key 1 ----------------------- [h]: Display help ------|\r\n");
01687
01688 }
01689 }
01690
01691 void C_GeneratorStats::makeDisplay2 () {
01692
01693 int L_i ;
01694
01695 m_mutexTable[CPT_C_AverageResponseTime].lock() ;
01696 m_displayCounters[CPT_C_AverageResponseTime]
01697 = m_counters[CPT_C_AverageResponseTime];
01698 m_displayCounters[CPT_PD_AverageResponseTime]
01699 = m_counters[CPT_PD_AverageResponseTime];
01700 m_mutexTable[CPT_C_AverageResponseTime].unlock() ;
01701
01702 DISPLAY_CROSS_LINE ();
01703 DISPLAY_INFO("Start/Stop timer repartition");
01704 DISPLAY_CROSS_LINE ();
01705 DISPLAY_TXT_COL ("Time (Periodic/Average)",
01706 msToHHMMSSmmm( m_displayCounters [CPT_PD_AverageResponseTime] ),
01707 msToHHMMSSmmm( m_displayCounters [CPT_C_AverageResponseTime] ) );
01708 DISPLAY_CROSS_LINE ();
01709 m_mutexTable[CPT_C_AverageResponseTime].lock() ;
01710
01711
01712 ((this)->*(m_current_repartition_display))
01713 (m_ResponseTimeRepartition, m_SizeOfResponseTimeRepartition);
01714
01715
01716 m_mutexTable[CPT_C_AverageResponseTime].unlock() ;
01717 DISPLAY_CROSS_LINE ();
01718 for (L_i = 0 ; L_i < (17 - m_SizeOfResponseTimeRepartition); L_i++) {
01719 DISPLAY_INFO((char*)"") ;
01720 }
01721 DISPLAY_CROSS_LINE ();
01722
01723 }
01724
01725 void C_GeneratorStats::displayRepartition ()
01726 {
01727 DISPLAY_INFO("Average Response Time Repartition");
01728 displayRepartition(m_ResponseTimeRepartition, m_SizeOfResponseTimeRepartition);
01729 DISPLAY_INFO("Average Call Length Repartition");
01730 displayRepartition(m_CallLengthRepartition, m_SizeOfCallLengthRepartition);
01731 }
01732
01733
01734 char* C_GeneratorStats::dumpCounters() {
01735
01736
01737 char * L_result_data = NULL;
01738 char L_buffer[MAX_CHAR_BUFFER_SIZE];
01739
01740
01741 long globalElapsedTime ;
01742 long localElapsedTime ;
01743 struct timeval currentTime ;
01744
01745 float AverageMsgRecvPerS;
01746 float AverageMsgSendPerS;
01747
01748 unsigned long L_numberOfCall ;
01749
01750
01751 unsigned long L_C_successful_call ;
01752 float realInstantCallRate ;
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800 m_mutexTable[CPT_C_IncomingCallCreated].lock() ;
01801 m_remoteCounters[CPT_C_IncomingCallCreated]
01802 = m_counters [CPT_C_IncomingCallCreated];
01803 m_remoteCounters[CPT_PD_IncomingCallCreated]
01804 = m_counters [CPT_PD_IncomingCallCreated];
01805 m_mutexTable[CPT_C_IncomingCallCreated].unlock() ;
01806
01807 m_mutexTable[CPT_C_OutgoingCallCreated].lock() ;
01808 m_remoteCounters[CPT_C_OutgoingCallCreated]
01809 = m_counters [CPT_C_OutgoingCallCreated];
01810 m_remoteCounters[CPT_PD_OutgoingCallCreated]
01811 = m_counters [CPT_PD_OutgoingCallCreated];
01812 m_mutexTable[CPT_C_OutgoingCallCreated].unlock() ;
01813
01814 m_mutexTable[CPT_C_InitSuccessfulCall].lock() ;
01815 m_remoteCounters[CPT_C_InitSuccessfulCall]
01816 = m_counters [CPT_C_InitSuccessfulCall];
01817 m_mutexTable[CPT_C_InitSuccessfulCall].unlock() ;
01818
01819 m_mutexTable[CPT_C_TrafficSuccessfulCall].lock() ;
01820 m_remoteCounters[CPT_C_TrafficSuccessfulCall]
01821 = m_counters [CPT_C_TrafficSuccessfulCall];
01822 m_mutexTable[CPT_C_TrafficSuccessfulCall].unlock() ;
01823
01824 m_mutexTable[CPT_C_DefaultSuccessfulCall].lock() ;
01825 m_remoteCounters[CPT_C_DefaultSuccessfulCall]
01826 = m_counters [CPT_C_DefaultSuccessfulCall];
01827 m_mutexTable[CPT_C_DefaultSuccessfulCall].unlock() ;
01828
01829 m_mutexTable[CPT_C_AbortSuccessfulCall].lock() ;
01830 m_remoteCounters[CPT_C_AbortSuccessfulCall]
01831 = m_counters [CPT_C_AbortSuccessfulCall];
01832 m_mutexTable[CPT_C_AbortSuccessfulCall].unlock() ;
01833
01834 m_mutexTable[CPT_C_FailedCall].lock() ;
01835 m_remoteCounters[CPT_C_FailedCall]
01836 = m_counters [CPT_C_FailedCall];
01837 m_mutexTable[CPT_C_FailedCall].unlock() ;
01838
01839 m_mutexTable[CPT_C_MsgSend].lock() ;
01840 m_remoteCounters[CPT_C_MsgSend]
01841 = m_counters [CPT_C_MsgSend];
01842 m_mutexTable[CPT_C_MsgSend].unlock() ;
01843
01844 m_mutexTable[CPT_C_MsgRecv].lock() ;
01845 m_remoteCounters[CPT_C_MsgRecv]
01846 = m_counters [CPT_C_MsgRecv];
01847 m_mutexTable[CPT_C_MsgRecv].unlock() ;
01848
01849
01850
01851 GET_TIME (¤tTime);
01852
01853 globalElapsedTime = ms_difftime (¤tTime, &m_startTime);
01854 localElapsedTime = ms_difftime (¤tTime, &m_pdStartTime);
01855
01856
01857
01858 L_C_successful_call =
01859 m_remoteCounters[CPT_C_InitSuccessfulCall] +
01860 m_remoteCounters[CPT_C_TrafficSuccessfulCall] +
01861 m_remoteCounters[CPT_C_DefaultSuccessfulCall] +
01862 m_remoteCounters[CPT_C_AbortSuccessfulCall] ;
01863
01864 L_numberOfCall
01865 = m_remoteCounters[CPT_PD_IncomingCallCreated]
01866 + m_remoteCounters[CPT_PD_OutgoingCallCreated];
01867
01868 realInstantCallRate
01869 = (localElapsedTime > 0 ?
01870 1000*(float)L_numberOfCall / (float)localElapsedTime :
01871 0.0);
01872
01873
01874 AverageMsgRecvPerS = (globalElapsedTime > 0 ?
01875 1000*((float)m_remoteCounters[CPT_C_MsgRecv]) / (float)globalElapsedTime :
01876 0.0);
01877
01878 AverageMsgSendPerS = (globalElapsedTime > 0 ?
01879 1000*((float)m_remoteCounters[CPT_C_MsgSend]) / (float)globalElapsedTime :
01880 0.0);
01881
01882
01883
01884 ALLOC_TABLE(L_result_data, char*, sizeof(char), 1024);
01885
01886
01887 sprintf(L_result_data, "%s%s\r\n",
01888 (char*)"elapsed_time=",
01889 msToHHMMSSmmm(globalElapsedTime));
01890
01891 sprintf(L_buffer, "%s%8.3f\r\n",
01892 (char*)"real_instant_call_rate_s=",
01893 realInstantCallRate);
01894 strcat(L_result_data, L_buffer);
01895
01896 sprintf(L_buffer, "%s%8ld\r\n",
01897 (char*)"incoming_calls=",
01898 m_remoteCounters[CPT_C_IncomingCallCreated]);
01899 strcat(L_result_data, L_buffer);
01900
01901
01902 sprintf(L_buffer, "%s%8ld\r\n",
01903 (char*)"outgoing_calls=",
01904 m_remoteCounters[CPT_C_OutgoingCallCreated]);
01905 strcat(L_result_data, L_buffer);
01906
01907 sprintf(L_buffer, "%s%8ld\r\n",
01908 (char*)"successful_calls=",
01909 L_C_successful_call);
01910 strcat(L_result_data, L_buffer);
01911
01912 sprintf(L_buffer, "%s%8ld\r\n",
01913 (char*)"failed_calls=",
01914 m_remoteCounters[CPT_C_FailedCall]);
01915 strcat(L_result_data, L_buffer);
01916
01917 sprintf(L_buffer, "%s%8.3f\r\n",
01918 (char*)"msg_recv_s=",
01919 AverageMsgRecvPerS);
01920 strcat(L_result_data, L_buffer);
01921
01922 sprintf(L_buffer, "%s%8.3f\r\n",
01923 (char*)"msg_sent_s=",
01924 AverageMsgSendPerS);
01925 strcat(L_result_data, L_buffer);
01926
01927
01928 return(L_result_data);
01929 }
01930
01931 void C_GeneratorStats::dumpData ()
01932 {
01933 long localElapsedTime, globalElapsedTime ;
01934 struct timeval currentTime;
01935 float averageCallRate;
01936 float realInstantCallRate;
01937 unsigned long numberOfCall;
01938
01939
01940 GET_TIME (¤tTime);
01941 globalElapsedTime = ms_difftime (¤tTime, &m_startTime);
01942 localElapsedTime = ms_difftime (¤tTime, &m_plStartTime);
01943
01944 numberOfCall = m_counters[CPT_C_IncomingCallCreated] + m_counters[CPT_C_OutgoingCallCreated];
01945 averageCallRate = (globalElapsedTime > 0 ? 1000*(float)numberOfCall/(float)globalElapsedTime : 0.0);
01946 numberOfCall = m_counters[CPT_PL_IncomingCallCreated] + m_counters[CPT_PL_OutgoingCallCreated];
01947 realInstantCallRate = (localElapsedTime > 0 ?
01948 1000*(float)numberOfCall / (float)localElapsedTime :
01949 0.0);
01950
01951
01952 if(m_outputStream == NULL)
01953 {
01954
01955 NEW_VAR(m_outputStream,
01956 fstream_output(m_fileName));
01957 m_headerAlreadyDisplayed = false;
01958
01959 if(m_outputStream == NULL) {
01960 iostream_error << "Unable to open log file !" << iostream_endl;
01961 exit(-1);
01962 }
01963
01964 if(!m_outputStream->good()) {
01965 iostream_error << "Unable to open log file !" << iostream_endl;
01966 exit(-1);
01967 }
01968 }
01969
01970 if(m_headerAlreadyDisplayed == false)
01971 {
01972
01973 (*m_outputStream) << "StartTime;"
01974 << "LastResetTime;"
01975 << "CurrentTime;"
01976 << "ElapsedTime(P);"
01977 << "ElapsedTime(C);"
01978 << "CallRate(P);"
01979 << "CallRate(C);"
01980 << "IncomingCall(P);"
01981 << "IncomingCall(C);"
01982 << "OutgoingCall(P);"
01983 << "OutgoingCall(C);"
01984 << "TotalCallCreated;"
01985 << "CurrentCall;"
01986 << "InitSuccessfulCall(P);"
01987 << "InitSuccessfulCall(C);"
01988 << "TrafficSuccessfulCall(P);"
01989 << "TrafficSuccessfulCall(C);"
01990 << "DefaultSuccessfulCall(P);"
01991 << "DefaultSuccessfulCall(C);"
01992 << "AbortSuccessfulCall(P);"
01993 << "AbortSuccessfulCall(C);"
01994 << "FailedCall(P);"
01995 << "FailedCall(C);"
01996 << "FailedCannotSendMessage(P);"
01997 << "FailedCannotSendMessage(C);"
01998 << "FailedMaxUDPRetrans(P);"
01999 << "FailedMaxUDPRetrans(C);"
02000 << "FailedUnexpectedMessage(P);"
02001 << "FailedUnexpectedMessage(C);"
02002 << "FailedCallRejected(P);"
02003 << "FailedCallRejected(C);"
02004 << "FailedCmdNotSent(P);"
02005 << "FailedCmdNotSent(C);"
02006 << "FailedRegexpDoesntMatch(P);"
02007 << "FailedRegexpDoesntMatch(C);"
02008 << "FailedRegexpHdrNotFound(P);"
02009 << "FailedRegexpHdrNotFound(C);"
02010 << "ResponseTime(P);"
02011 << "ResponseTime(C);"
02012 << "CallLength(P);"
02013 << "CallLength(C);";
02014 (*m_outputStream) << sRepartitionHeader(m_ResponseTimeRepartition, m_SizeOfResponseTimeRepartition,
02015 (char*) "ResponseTimeRepartition");
02016 (*m_outputStream) << sRepartitionHeader(m_CallLengthRepartition, m_SizeOfCallLengthRepartition,
02017 (char*) "CallLengthRepartition");
02018 (*m_outputStream) << iostream_endl;
02019 m_headerAlreadyDisplayed = true;
02020 }
02021
02022
02023 (*m_outputStream) << formatTime(&m_startTime) << ";";
02024 (*m_outputStream) << formatTime(&m_plStartTime) << ";";
02025 (*m_outputStream) << formatTime(¤tTime) << ";"
02026 << msToHHMMSS(localElapsedTime) << ";";
02027 (*m_outputStream) << msToHHMMSS(globalElapsedTime) << ";"
02028 << realInstantCallRate << ";"
02029 << averageCallRate << ";"
02030 << m_counters[CPT_PL_IncomingCallCreated] << ";"
02031 << m_counters[CPT_C_IncomingCallCreated] << ";"
02032 << m_counters[CPT_PL_OutgoingCallCreated] << ";"
02033 << m_counters[CPT_C_OutgoingCallCreated] << ";"
02034 << m_counters[CPT_C_IncomingCallCreated]+
02035 m_counters[CPT_C_OutgoingCallCreated] << ";"
02036 << m_counters[CPT_C_CurrentCall] << ";"
02037 << m_counters[CPT_PL_InitSuccessfulCall] << ";"
02038 << m_counters[CPT_C_InitSuccessfulCall] << ";"
02039 << m_counters[CPT_PL_TrafficSuccessfulCall] << ";"
02040 << m_counters[CPT_C_TrafficSuccessfulCall] << ";"
02041 << m_counters[CPT_PL_DefaultSuccessfulCall] << ";"
02042 << m_counters[CPT_C_DefaultSuccessfulCall] << ";"
02043 << m_counters[CPT_PL_AbortSuccessfulCall] << ";"
02044 << m_counters[CPT_C_AbortSuccessfulCall] << ";"
02045 << m_counters[CPT_PL_FailedCall] << ";"
02046 << m_counters[CPT_C_FailedCall] << ";"
02047 << m_counters[CPT_PL_FailedCallCannotSendMessage] << ";"
02048 << m_counters[CPT_C_FailedCallCannotSendMessage] << ";"
02049 << m_counters[CPT_PL_FailedCallMaxUdpRetrans] << ";"
02050 << m_counters[CPT_C_FailedCallMaxUdpRetrans] << ";"
02051 << m_counters[CPT_PL_FailedCallUnexpectedMessage] << ";"
02052 << m_counters[CPT_C_FailedCallUnexpectedMessage] << ";"
02053 << m_counters[CPT_PL_FailedCallCallRejected] << ";"
02054 << m_counters[CPT_C_FailedCallCallRejected] << ";"
02055 << m_counters[CPT_PL_FailedCallCmdNotSent] << ";"
02056 << m_counters[CPT_C_FailedCallCmdNotSent] << ";"
02057 << m_counters[CPT_PL_FailedCallRegexpDoesntMatch] << ";"
02058 << m_counters[CPT_C_FailedCallRegexpDoesntMatch] << ";"
02059 << m_counters[CPT_PL_FailedCallRegexpHdrNotFound] << ";"
02060 << m_counters[CPT_C_FailedCallRegexpHdrNotFound] << ";";
02061
02062 (*m_outputStream) << msToHHMMSSmmm( m_counters [CPT_PL_AverageResponseTime] ) << ";";
02063 (*m_outputStream) << msToHHMMSSmmm( m_counters [CPT_C_AverageResponseTime ] ) << ";";
02064 (*m_outputStream) << msToHHMMSSmmm( m_counters [CPT_PL_AverageCallLength ] ) << ";";
02065 (*m_outputStream) << msToHHMMSSmmm( m_counters [CPT_C_AverageCallLength ] ) << ";";
02066 (*m_outputStream) << sRepartitionInfo(m_ResponseTimeRepartition, m_SizeOfResponseTimeRepartition);
02067 (*m_outputStream) << sRepartitionInfo(m_CallLengthRepartition, m_SizeOfCallLengthRepartition);
02068 (*m_outputStream) << iostream_endl;
02069
02070
02071 (*m_outputStream).flush();
02072
02073 }
02074
02075
02076
02077
02078
02079 void C_GeneratorStats::makeLog ()
02080 {
02081
02082 long localElapsedTime ;
02083 long globalElapsedTime ;
02084 struct timeval currentTime ;
02085
02086 float MsgSendPerS;
02087 float MsgRecvPerS;
02088 float AverageMsgRecvPerS;
02089 float AverageMsgSendPerS;
02090
02091 unsigned long numberOfCall;
02092 float realInstantCallRate ;
02093 float averageCallRate ;
02094
02095
02096
02097
02098
02099
02100 m_mutexTable[CPT_C_IncomingCallCreated].lock() ;
02101 m_loggingCounters[CPT_C_IncomingCallCreated]
02102 = m_counters [CPT_C_IncomingCallCreated];
02103 m_loggingCounters[CPT_PL_IncomingCallCreated]
02104 = m_counters [CPT_PL_IncomingCallCreated];
02105 m_mutexTable[CPT_C_IncomingCallCreated].unlock() ;
02106
02107 m_mutexTable[CPT_C_CurrentCall].lock();
02108 m_loggingCounters[CPT_C_CurrentCall]
02109 = m_counters [CPT_C_CurrentCall];
02110 m_mutexTable[CPT_C_CurrentCall].unlock();
02111
02112 m_mutexTable[CPT_C_MsgSend].lock() ;
02113 m_loggingCounters[CPT_C_MsgSend]
02114 = m_counters [CPT_C_MsgSend];
02115 m_loggingCounters[CPT_PL_MsgSend]
02116 = m_counters [CPT_PL_MsgSend];
02117 m_mutexTable[CPT_C_MsgSend].unlock() ;
02118
02119 m_mutexTable[CPT_C_MsgRecv].lock() ;
02120 m_loggingCounters[CPT_C_MsgRecv]
02121 = m_counters [CPT_C_MsgRecv];
02122 m_loggingCounters[CPT_PL_MsgRecv]
02123 = m_counters [CPT_PL_MsgRecv];
02124 m_mutexTable[CPT_C_MsgRecv].unlock() ;
02125
02126 m_mutexTable[CPT_C_FailedCall].lock() ;
02127 m_loggingCounters[CPT_C_FailedCall]
02128 = m_counters [CPT_C_FailedCall];
02129 m_loggingCounters[CPT_PL_FailedCall]
02130 = m_counters [CPT_PL_FailedCall];
02131 m_mutexTable[CPT_C_FailedCall].unlock() ;
02132
02133 m_mutexTable[CPT_C_InitSuccessfulCall].lock() ;
02134 m_loggingCounters[CPT_C_InitSuccessfulCall]
02135 = m_counters [CPT_C_InitSuccessfulCall];
02136 m_loggingCounters[CPT_PL_InitSuccessfulCall]
02137 = m_counters [CPT_PL_InitSuccessfulCall];
02138 m_mutexTable[CPT_C_InitSuccessfulCall].unlock() ;
02139
02140 m_mutexTable[CPT_C_TrafficSuccessfulCall].lock() ;
02141 m_loggingCounters[CPT_C_TrafficSuccessfulCall]
02142 = m_counters [CPT_C_TrafficSuccessfulCall];
02143 m_loggingCounters[CPT_PL_TrafficSuccessfulCall]
02144 = m_counters [CPT_PL_TrafficSuccessfulCall];
02145 m_mutexTable[CPT_C_TrafficSuccessfulCall].unlock() ;
02146
02147 m_mutexTable[CPT_C_DefaultSuccessfulCall].lock() ;
02148 m_loggingCounters[CPT_C_DefaultSuccessfulCall]
02149 = m_counters [CPT_C_DefaultSuccessfulCall];
02150 m_loggingCounters[CPT_PL_DefaultSuccessfulCall]
02151 = m_counters [CPT_PL_DefaultSuccessfulCall];
02152 m_mutexTable[CPT_C_DefaultSuccessfulCall].unlock() ;
02153
02154 m_mutexTable[CPT_C_AbortSuccessfulCall].lock() ;
02155 m_loggingCounters[CPT_C_AbortSuccessfulCall]
02156 = m_counters [CPT_C_AbortSuccessfulCall];
02157 m_loggingCounters[CPT_PL_AbortSuccessfulCall]
02158 = m_counters [CPT_PL_AbortSuccessfulCall];
02159 m_mutexTable[CPT_C_AbortSuccessfulCall].unlock() ;
02160
02161 m_mutexTable[CPT_C_FailedCallCannotSendMessage].lock() ;
02162 m_loggingCounters[CPT_C_FailedCallCannotSendMessage]
02163 = m_counters [CPT_C_FailedCallCannotSendMessage];
02164 m_loggingCounters[CPT_PL_FailedCallCannotSendMessage]
02165 = m_counters [CPT_PL_FailedCallCannotSendMessage];
02166 m_mutexTable[CPT_C_FailedCallCannotSendMessage].unlock() ;
02167
02168 m_mutexTable[CPT_C_FailedCallUnexpectedMessage].lock() ;
02169 m_loggingCounters[CPT_C_FailedCallUnexpectedMessage]
02170 = m_counters [CPT_C_FailedCallUnexpectedMessage];
02171 m_loggingCounters[CPT_PL_FailedCallUnexpectedMessage]
02172 = m_counters [CPT_PL_FailedCallUnexpectedMessage];
02173 m_mutexTable[CPT_C_FailedCallUnexpectedMessage].unlock() ;
02174
02175 m_mutexTable[CPT_C_RefusedCall].lock() ;
02176 m_loggingCounters[CPT_C_RefusedCall]
02177 = m_counters [CPT_C_RefusedCall];
02178 m_loggingCounters[CPT_PL_RefusedCall]
02179 = m_counters [CPT_PL_RefusedCall];
02180 m_mutexTable[CPT_C_RefusedCall].unlock() ;
02181
02182 m_mutexTable[CPT_C_FailedCallAborted].lock() ;
02183 m_loggingCounters[CPT_C_FailedCallAborted]
02184 = m_counters [CPT_C_FailedCallAborted];
02185 m_loggingCounters[CPT_PL_FailedCallAborted]
02186 = m_counters [CPT_PL_FailedCallAborted];
02187 m_mutexTable[CPT_C_FailedCallAborted].unlock() ;
02188
02189 m_mutexTable[CPT_C_FailedCallTimeout].lock() ;
02190 m_loggingCounters[CPT_C_FailedCallTimeout]
02191 = m_counters [CPT_C_FailedCallTimeout];
02192 m_loggingCounters[CPT_PL_FailedCallTimeout]
02193 = m_counters [CPT_PL_FailedCallTimeout];
02194 m_mutexTable[CPT_C_FailedCallTimeout].unlock() ;
02195
02196 m_mutexTable[CPT_C_OutgoingCallCreated].lock() ;
02197 m_loggingCounters[CPT_C_OutgoingCallCreated]
02198 = m_counters [CPT_C_OutgoingCallCreated];
02199 m_loggingCounters[CPT_PL_OutgoingCallCreated]
02200 = m_counters [CPT_PL_OutgoingCallCreated];
02201 m_mutexTable[CPT_C_OutgoingCallCreated].unlock() ;
02202
02203
02204
02205 GET_TIME (¤tTime);
02206
02207 globalElapsedTime = ms_difftime (¤tTime, &m_startTime);
02208 localElapsedTime = ms_difftime (¤tTime, &m_plStartTime);
02209
02210
02211 numberOfCall
02212 = m_loggingCounters[CPT_C_IncomingCallCreated]
02213 + m_loggingCounters[CPT_C_OutgoingCallCreated];
02214
02215 averageCallRate
02216 = (globalElapsedTime > 0 ?
02217 1000*(float)numberOfCall/(float)globalElapsedTime : 0.0);
02218
02219 numberOfCall
02220 = m_loggingCounters[CPT_PL_IncomingCallCreated]
02221 + m_loggingCounters[CPT_PL_OutgoingCallCreated];
02222
02223 realInstantCallRate
02224 = (localElapsedTime > 0 ?
02225 1000*(float)numberOfCall / (float)localElapsedTime :
02226 0.0);
02227
02228 MsgRecvPerS = (localElapsedTime > 0 ?
02229 1000*((float)m_loggingCounters[CPT_PL_MsgRecv]) / (float)localElapsedTime :
02230 0.0);
02231
02232 MsgSendPerS = (localElapsedTime > 0 ?
02233 1000*((float)m_loggingCounters[CPT_PL_MsgSend]) / (float)localElapsedTime :
02234 0.0);
02235
02236 AverageMsgRecvPerS = (globalElapsedTime > 0 ?
02237 1000*((float)m_loggingCounters[CPT_C_MsgRecv]) / (float)globalElapsedTime :
02238 0.0);
02239
02240 AverageMsgSendPerS = (globalElapsedTime > 0 ?
02241 1000*((float)m_loggingCounters[CPT_C_MsgSend]) / (float)globalElapsedTime :
02242 0.0);
02243
02244
02245
02246
02247
02248 (*m_outputStream) << formatTime(&m_startTime) << ";";
02249 (*m_outputStream) << formatTime(&m_pdStartTime) << ";";
02250 (*m_outputStream) << formatTime(¤tTime) << ";"
02251 << msToHHMMSS(localElapsedTime) << ";";
02252 (*m_outputStream) << msToHHMMSS(globalElapsedTime) << ";"
02253 << realInstantCallRate << ";"
02254 << averageCallRate << ";"
02255 << m_loggingCounters[CPT_PL_IncomingCallCreated] << ";"
02256 << m_loggingCounters[CPT_C_IncomingCallCreated] << ";"
02257 << m_loggingCounters[CPT_PL_OutgoingCallCreated] << ";"
02258 << m_loggingCounters[CPT_C_OutgoingCallCreated] << ";"
02259 << MsgRecvPerS << ";"
02260 << AverageMsgRecvPerS << ";"
02261 << MsgSendPerS << ";"
02262 << AverageMsgSendPerS << ";"
02263 << m_loggingCounters[CPT_PL_FailedCallUnexpectedMessage] << ";"
02264 << m_loggingCounters[CPT_C_FailedCallUnexpectedMessage] << ";"
02265 << m_loggingCounters[CPT_C_CurrentCall] << ";"
02266 << m_loggingCounters[CPT_PL_InitSuccessfulCall] << ";"
02267 << m_loggingCounters[CPT_C_InitSuccessfulCall] << ";"
02268 << m_loggingCounters[CPT_PL_TrafficSuccessfulCall] << ";"
02269 << m_loggingCounters[CPT_C_TrafficSuccessfulCall] << ";"
02270 << m_loggingCounters[CPT_PL_DefaultSuccessfulCall] << ";"
02271 << m_loggingCounters[CPT_C_DefaultSuccessfulCall] << ";"
02272 << m_loggingCounters[CPT_PL_AbortSuccessfulCall] << ";"
02273 << m_loggingCounters[CPT_C_AbortSuccessfulCall] << ";"
02274 << m_loggingCounters[CPT_PL_FailedCall] << ";"
02275 << m_loggingCounters[CPT_C_FailedCall] << ";"
02276 << m_loggingCounters[CPT_PL_RefusedCall] << ";"
02277 << m_loggingCounters[CPT_C_RefusedCall] << ";"
02278 << m_loggingCounters[CPT_PL_FailedCallAborted] << ";"
02279 << m_loggingCounters[CPT_C_FailedCallAborted] << ";"
02280 << m_loggingCounters[CPT_PL_FailedCallTimeout] << ";"
02281 << m_loggingCounters[CPT_C_FailedCallTimeout] << ";" ;
02282 m_mutexTable[CPT_C_AverageResponseTime].lock() ;
02283 (*m_outputStream) << msToHHMMSSmmm( m_counters [CPT_PL_AverageResponseTime] ) << ";" ;
02284 (*m_outputStream) << msToHHMMSSmmm( m_counters [CPT_C_AverageResponseTime ] ) << ";" ;
02285 (*m_outputStream) << sRepartitionInfo(m_ResponseTimeRepartition, m_SizeOfResponseTimeRepartition);
02286 m_mutexTable[CPT_C_AverageResponseTime].unlock() ;
02287
02288
02289 (*m_outputStream) << iostream_endl;
02290
02291
02292 (*m_outputStream).flush();
02293
02294 }
02295
02296
02297
02298 void C_GeneratorStats::makeFirstLog ()
02299 {
02300
02301 if(m_outputStream == NULL)
02302 {
02303
02304 NEW_VAR(m_outputStream,
02305 fstream_output(m_fileName));
02306 m_headerAlreadyDisplayed = false;
02307
02308 if(m_outputStream == NULL) {
02309 iostream_error << "Unable to open log file !" << iostream_endl;
02310 exit(-1);
02311 }
02312
02313 if(!m_outputStream->good()) {
02314 iostream_error << "Unable to open log file !" << iostream_endl;
02315 exit(-1);
02316 }
02317 }
02318
02319
02320 (*m_outputStream) << "StartTime;"
02321 << "LastResetTime;"
02322 << "CurrentTime;"
02323 << "ElapsedTime(P);"
02324 << "ElapsedTime(C);"
02325 << "Rate(P);"
02326 << "Rate(C);"
02327 << "IncomingCall(P);"
02328 << "IncomingCall(C);"
02329 << "OutgoingCall(P);"
02330 << "OutgoingCall(C);"
02331 << "MsgRecvPerS(P);"
02332 << "MsgRecvPerS(C);"
02333 << "MsgSendPerS(P);"
02334 << "MsgSendPerS(C);"
02335 << "UnexpectedMsg(P);"
02336 << "UnexpectedMsg(C);"
02337 << "CurrentCall;"
02338 << "InitSuccessfulCall(P);"
02339 << "InitSuccessfulCall(C);"
02340 << "TrafficSuccessfulCall(P);"
02341 << "TrafficSuccessfulCall(C);"
02342 << "DefaultSuccessfulCall(P);"
02343 << "DefaultSuccessfulCall(C);"
02344 << "AbortSuccessfulCall(P);"
02345 << "AbortSuccessfulCall(C);"
02346 << "FailedCall(P);"
02347 << "FailedCall(C);"
02348 << "FailedRefused(P);"
02349 << "FailedRefused(C);"
02350 << "FailedAborted(P);"
02351 << "FailedAborted(C);"
02352 << "FailedTimeout(P);"
02353 << "FailedTimeout(C);"
02354 << "ResponseTime(P);"
02355 << "ResponseTime(C);" ;
02356 (*m_outputStream) << sRepartitionHeader(m_ResponseTimeRepartition,
02357 m_SizeOfResponseTimeRepartition,
02358 (char*) "ResponseTimeRepartition");
02359 (*m_outputStream) << iostream_endl;
02360
02361 (*m_outputStream).flush();
02362
02363 }
02364
02365
02366
02367
02368
02369
02370 char* C_GeneratorStats::msToHHMMSS (unsigned long P_ms)
02371 {
02372 static char L_time [TIME_LENGTH];
02373 unsigned long hh, mm, ss;
02374
02375 P_ms = P_ms / 1000;
02376 hh = P_ms / 3600;
02377 mm = (P_ms - hh * 3600) / 60;
02378 ss = P_ms - (hh * 3600) - (mm * 60);
02379 sprintf (L_time, "%2.2ld:%2.2ld:%2.2ld", hh, mm, ss);
02380 return (L_time);
02381 }
02382
02383 char* C_GeneratorStats::msToHHMMSSmmm (unsigned long P_ms)
02384 {
02385 static char L_time [TIME_LENGTH];
02386 unsigned long sec, hh, mm, ss, mmm;
02387
02388 sec = P_ms / 1000;
02389 hh = sec / 3600;
02390 mm = (sec - hh * 3600) / 60;
02391 ss = sec - (hh * 3600) - (mm * 60);
02392 mmm = P_ms - (hh * 3600000) - (mm * 60000) - (ss*1000);
02393 sprintf (L_time, "%2.2ld:%2.2ld:%2.2ld:%3.3ld", hh, mm, ss, mmm);
02394 return (L_time);
02395 }
02396
02397
02398 void C_GeneratorStats::formatTime (char *P_time, struct timeval* P_tv)
02399 {
02400 struct tm * L_currentDate;
02401
02402
02403 L_currentDate = localtime ((const time_t *)&P_tv->tv_sec);
02404
02405
02406 if (L_currentDate == NULL)
02407 {
02408 memset (P_time, 0, TIME_LENGTH);
02409 }
02410 else
02411 {
02412 sprintf(P_time, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d",
02413 L_currentDate->tm_year + 1900,
02414 L_currentDate->tm_mon + 1,
02415 L_currentDate->tm_mday,
02416 L_currentDate->tm_hour,
02417 L_currentDate->tm_min,
02418 L_currentDate->tm_sec);
02419
02420 }
02421 }
02422
02423
02424 char* C_GeneratorStats::formatTime (struct timeval* P_tv)
02425 {
02426 static char L_time [TIME_LENGTH];
02427 struct tm * L_currentDate;
02428
02429
02430 L_currentDate = localtime ((const time_t *)&P_tv->tv_sec);
02431
02432
02433 if (L_currentDate == NULL)
02434 {
02435 memset (L_time, 0, TIME_LENGTH);
02436 }
02437 else
02438 {
02439 sprintf(L_time, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d",
02440 L_currentDate->tm_year + 1900,
02441 L_currentDate->tm_mon + 1,
02442 L_currentDate->tm_mday,
02443 L_currentDate->tm_hour,
02444 L_currentDate->tm_min,
02445 L_currentDate->tm_sec);
02446
02447 }
02448 return (L_time);
02449 }
02450
02451 int C_GeneratorStats::executeStatAction (E_Action P_action, unsigned long P_value)
02452 {
02453 switch (P_action)
02454 {
02455 case E_ADD_RESPONSE_TIME_DURATION :
02456 m_mutexTable[CPT_C_AverageResponseTime].lock() ;
02457
02458 updateAverageCounter(CPT_C_AverageResponseTime,
02459 CPT_C_NbOfCallUsedForAverageResponseTime,
02460 &m_C_sumResponseTime, P_value);
02461 updateRepartition(m_ResponseTimeRepartition,
02462 m_SizeOfResponseTimeRepartition, P_value);
02463
02464 updateAverageCounter(CPT_PD_AverageResponseTime,
02465 CPT_PD_NbOfCallUsedForAverageResponseTime,
02466 &m_PD_sumResponseTime,
02467 P_value);
02468
02469 updateAverageCounter(CPT_PL_AverageResponseTime,
02470 CPT_PL_NbOfCallUsedForAverageResponseTime,
02471 &m_PL_sumResponseTime,
02472 P_value);
02473 m_mutexTable[CPT_C_AverageResponseTime].unlock() ;
02474 break;
02475
02476 default :
02477 GEN_FATAL(0,"C_GeneratorStats::executeStatAction() - Unrecognized Action "
02478 << P_action << " " << P_value);
02479 }
02480 return (0);
02481 }
02482
02483
02484 void C_GeneratorStats::info_msg (char *P_msg) {
02485 if (strlen(P_msg) < m_max_msg_size) {
02486 strcpy(m_info_msg, P_msg);
02487 } else {
02488 strncpy(m_info_msg, P_msg, m_max_msg_size);
02489 m_info_msg[m_max_msg_size]='\0' ;
02490 }
02491 }
02492
02493 void C_GeneratorStats::err_msg (char *P_msg) {
02494 if (strlen(P_msg) < m_max_msg_size) {
02495 strcpy(m_err_msg, P_msg);
02496 } else {
02497 strncpy(m_err_msg, P_msg, m_max_msg_size);
02498 m_err_msg[m_max_msg_size]='\0' ;
02499 }
02500 }
02501
02502
02503
02504 C_GeneratorStats* C_GeneratorStats::m_instance = NULL;
02505