From: <cha...@us...> - 2008-07-14 20:11:53
|
Revision: 507 http://sipp.svn.sourceforge.net/sipp/?rev=507&view=rev Author: charlespwright Date: 2008-07-14 13:11:51 -0700 (Mon, 14 Jul 2008) Log Message: ----------- Enh: Allow arbitrary number of Response Time Durations with text names. Modified Paths: -------------- sipp/trunk/call.cpp sipp/trunk/call.hpp sipp/trunk/scenario.cpp sipp/trunk/scenario.hpp sipp/trunk/sipp.cpp sipp/trunk/stat.cpp sipp/trunk/stat.hpp Modified: sipp/trunk/call.cpp =================================================================== --- sipp/trunk/call.cpp 2008-07-14 19:23:46 UTC (rev 506) +++ sipp/trunk/call.cpp 2008-07-14 20:11:51 UTC (rev 507) @@ -461,7 +461,15 @@ // If not updated by a message we use the start time // information to compute rtd information - for (i = 0; i < MAX_RTD_INFO_LENGTH; i++) { + start_time_rtd = (unsigned long long *)malloc(sizeof(unsigned long long) * call_scenario->stats->nRtds()); + if (!start_time_rtd) { + ERROR("Could not allocate RTD times!"); + } + rtd_done = (bool *)malloc(sizeof(bool) * call_scenario->stats->nRtds()); + if (!start_time_rtd) { + ERROR("Could not allocate RTD done!"); + } + for (i = 0; i < call_scenario->stats->nRtds(); i++) { start_time_rtd[i] = getmicroseconds(); rtd_done[i] = false; } Modified: sipp/trunk/call.hpp =================================================================== --- sipp/trunk/call.hpp 2008-07-14 19:23:46 UTC (rev 506) +++ sipp/trunk/call.hpp 2008-07-14 20:11:51 UTC (rev 507) @@ -172,10 +172,9 @@ unsigned int paused_until; unsigned long start_time; - unsigned long long start_time_rtd[MAX_RTD_INFO_LENGTH]; + unsigned long long *start_time_rtd; + bool *rtd_done; - bool rtd_done[MAX_RTD_INFO_LENGTH]; - char *peer_tag; struct sipp_socket *call_remote_socket; Modified: sipp/trunk/scenario.cpp =================================================================== --- sipp/trunk/scenario.cpp 2008-07-14 19:23:46 UTC (rev 506) +++ sipp/trunk/scenario.cpp 2008-07-14 20:11:51 UTC (rev 507) @@ -508,25 +508,14 @@ /* For backwards compatibility, we assign "true" to slot 1, false to 0, and * allow other valid integers. */ -int get_rtd(const char *ptr) { - char *endptr; - int ret; - - if(!strcmp(ptr, (char *)"true")) - return 1; +int scenario::get_rtd(const char *ptr, bool start) { if(!strcmp(ptr, (char *)"false")) return 0; - ret = strtol(ptr, &endptr, 0); - if (*endptr) { - ERROR("rtd \"%s\" is not a valid integer!\n", ptr); - } + if(!strcmp(ptr, (char *)"true")) + return stats->findRtd("1", start); - if (ret > MAX_RTD_INFO_LENGTH) { - ERROR("rtd %d exceeds MAX_RTD_INFO_LENGTH %d!\n", ret, MAX_RTD_INFO_LENGTH); - } - - return ret; + return stats->findRtd(ptr, start); } /* Get a counter */ @@ -545,15 +534,6 @@ /* Some validation functions. */ -/* If you start an RTD, then you should be interested in collecting statistics for it. */ -void scenario::validate_rtds() { - for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) { - if (rtd_started[i] && !rtd_stopped[i]) { - ERROR("You have started Response Time Duration %d, but have never stopped it!", i + 1); - } - } -} - void scenario::validate_variable_usage() { allocVars->validate(); } @@ -594,13 +574,6 @@ } } -void scenario::init_rtds() -{ - for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) { - rtd_started[i] = rtd_stopped[i] = false; - } -} - int get_cr_number(char *src) { int res=0; @@ -684,7 +657,6 @@ stats = new CStat(); allocVars = new AllocVariableTable(userVariables); - init_rtds(); hidedefault = false; elem = xp_open_element(0); @@ -1055,10 +1027,7 @@ apply_labels(initmessages, initLabelMap); /* Some post-scenario loading validation. */ - validate_rtds(); - if (messages.size() == 0) { - ERROR("Did not find any messages inside of scenario!"); - } + stats->validateRtds(); /* Make sure that all variables are used more than once. */ validate_variable_usage(); @@ -1066,6 +1035,9 @@ /* Make sure that all started transactions have responses, and vice versa. */ validate_txn_usage(); + if (messages.size() == 0) { + ERROR("Did not find any messages inside of scenario!"); + } } void scenario::runInit() { @@ -1652,8 +1624,7 @@ char *ptr; if((ptr = xp_get_value((char *)"rtd"))) { - message -> stop_rtd = get_rtd(ptr); - rtd_stopped[message->stop_rtd - 1] = true; + message -> stop_rtd = get_rtd(ptr, false); } if ((ptr = xp_get_value((char *)"repeat_rtd"))) { if (message -> stop_rtd) { @@ -1664,8 +1635,7 @@ } if((ptr = xp_get_value((char *)"start_rtd"))) { - message -> start_rtd = get_rtd(ptr); - rtd_started[message->start_rtd - 1] = true; + message -> start_rtd = get_rtd(ptr, true); } if((ptr = xp_get_value((char *)"counter"))) { Modified: sipp/trunk/scenario.hpp =================================================================== --- sipp/trunk/scenario.hpp 2008-07-14 19:23:46 UTC (rev 506) +++ sipp/trunk/scenario.hpp 2008-07-14 20:11:51 UTC (rev 507) @@ -183,9 +183,9 @@ void computeSippMode(); - bool rtd_stopped[MAX_RTD_INFO_LENGTH]; int get_var(const char *varName, const char *what); int get_counter(const char *varName, const char *what); + int get_rtd(const char *ptr, bool start); int find_var(const char *varName, const char *what); CStat *stats; @@ -200,7 +200,6 @@ str_int_map txnMap; bool found_timewait; - bool rtd_started[MAX_RTD_INFO_LENGTH]; void getBookKeeping(message *message); void getCommonAttributes(message *message); @@ -210,8 +209,6 @@ void handle_rhs(CAction *tmpAction, char *what); void apply_labels(msgvec v, str_int_map labels); - void init_rtds(); - void validate_rtds(); void validate_variable_usage(); void validate_txn_usage(); Modified: sipp/trunk/sipp.cpp =================================================================== --- sipp/trunk/sipp.cpp 2008-07-14 19:23:46 UTC (rev 506) +++ sipp/trunk/sipp.cpp 2008-07-14 20:11:51 UTC (rev 507) @@ -1369,10 +1369,9 @@ print_bottom_line( screenf, 0); currentScreenToDisplay = DISPLAY_SECONDARY_REPARTITION_SCREEN; - for (int i = 1; i <= MAX_RTD_INFO_LENGTH; i++) { - currentRepartitionToDisplay = i; + for (currentRepartitionToDisplay = 2; currentRepartitionToDisplay <= display_scenario->stats->nRtds(); currentRepartitionToDisplay++) { print_header_line( screenf, 0); - display_scenario->stats->displaySecondaryRepartition(screenf, i-1); + display_scenario->stats->displayRtdRepartition(screenf, currentRepartitionToDisplay); print_bottom_line( screenf, 0); } @@ -1412,7 +1411,7 @@ print_tdm_map(); break; case DISPLAY_SECONDARY_REPARTITION_SCREEN : - display_scenario->stats->displaySecondaryRepartition(stdout, currentRepartitionToDisplay - 1); + display_scenario->stats->displayRtdRepartition(stdout, currentRepartitionToDisplay); break; case DISPLAY_SCENARIO_SCREEN : default: @@ -1495,7 +1494,7 @@ case '8': case '9': currentScreenToDisplay = DISPLAY_SECONDARY_REPARTITION_SCREEN; - currentRepartitionToDisplay = (c - '6') + 1; + currentRepartitionToDisplay = (c - '6') + 2; print_statistics(0); break; @@ -3300,6 +3299,9 @@ screentask::report(true); stattask::report(); + if (screenf) { + print_screens(); + } screen_exit(EXIT_TEST_RES_UNKNOWN); } Modified: sipp/trunk/stat.cpp =================================================================== --- sipp/trunk/stat.cpp 2008-07-14 19:23:46 UTC (rev 506) +++ sipp/trunk/stat.cpp 2008-07-14 20:11:51 UTC (rev 507) @@ -103,6 +103,11 @@ for (unsigned int j=0;j<M_genericMap.size(); j++) { \ M_genericCounters[j * GENERIC_TYPES + GENERIC_PD] = 0; \ } \ + for (unsigned int j=0;j<M_rtdMap.size(); j++) { \ + M_rtdInfo[(j * GENERIC_TYPES * RTD_TYPES) + (GENERIC_PD * RTD_TYPES) + RTD_COUNT] = 0; \ + M_rtdInfo[(j * GENERIC_TYPES * RTD_TYPES) + (GENERIC_PD * RTD_TYPES) + RTD_SUM] = 0; \ + M_rtdInfo[(j * GENERIC_TYPES * RTD_TYPES) + (GENERIC_PD * RTD_TYPES) + RTD_SUMSQ] = 0; \ + } \ } #define RESET_PL_COUNTERS \ @@ -119,6 +124,11 @@ for (unsigned int j=0;j<M_genericMap.size(); j++) { \ M_genericCounters[j * GENERIC_TYPES + GENERIC_PL] = 0; \ } \ + for (unsigned int j=0;j<M_rtdMap.size(); j++) { \ + M_rtdInfo[(j * GENERIC_TYPES * RTD_TYPES) + (GENERIC_PL * RTD_TYPES) + RTD_COUNT] = 0; \ + M_rtdInfo[(j * GENERIC_TYPES * RTD_TYPES) + (GENERIC_PL * RTD_TYPES) + RTD_SUM] = 0; \ + M_rtdInfo[(j * GENERIC_TYPES * RTD_TYPES) + (GENERIC_PL * RTD_TYPES) + RTD_SUMSQ] = 0; \ + } \ } /* @@ -134,7 +144,7 @@ { int i; - for (i = 0; i < MAX_RTD_INFO_LENGTH; i++) { + for (i = 0; i < nRtds(); i++) { if (M_ResponseTimeRepartition[i] != NULL) { delete [] M_ResponseTimeRepartition[i]; } @@ -443,7 +453,7 @@ int sizeOfListe; int i; - for (i = 0; i < MAX_RTD_INFO_LENGTH; i++) { + for (i = 0; i < nRtds(); i++) { if(createIntegerTable(P_listeStr, &listeInteger, &sizeOfListe) == 1) { initRepartition(listeInteger, sizeOfListe, @@ -470,7 +480,7 @@ void CStat::setRepartitionResponseTime(unsigned int* repartition, int nombre) { - for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) { + for (int i = 0; i < nRtds(); i++) { initRepartition(repartition, nombre, &M_ResponseTimeRepartition[i], @@ -678,7 +688,7 @@ GET_TIME (&M_plStartTime); if (periodic_rtd) { resetRepartition(M_CallLengthRepartition, M_SizeOfCallLengthRepartition); - for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) { + for (int i = 0; i < nRtds(); i++) { resetRepartition(M_ResponseTimeRepartition[i], M_SizeOfResponseTimeRepartition); } } @@ -777,7 +787,7 @@ double CStat::computeStdev(E_CounterName P_SumCounter, E_CounterName P_NbOfCallUsed, E_CounterName P_Squares) { - if (M_counters[P_NbOfCallUsed] == 0) + if (M_counters[P_NbOfCallUsed] <= 0) return 0.0; double numerator = ((double)(M_counters[P_NbOfCallUsed]) * (double)(M_counters[P_Squares])) - ((double)(M_counters[P_SumCounter] * M_counters[P_SumCounter])); @@ -793,6 +803,29 @@ return ((double)(M_counters[P_SumCounter]) / (double)(M_counters[P_NbOfCallUsed])); } +double CStat::computeRtdMean(int which, int type) { + unsigned long long count = M_rtdInfo[((which - 1) * RTD_TYPES * GENERIC_TYPES) + (type * RTD_TYPES) + RTD_COUNT]; + unsigned long long sum = M_rtdInfo[((which - 1) * RTD_TYPES * GENERIC_TYPES) + (type * RTD_TYPES) + RTD_SUM]; + + if (count == 0) + return 0.0; + return ((double)(sum) / (double)(count)); +} + +double CStat::computeRtdStdev(int which, int type) { + unsigned long long count = M_rtdInfo[((which - 1) * RTD_TYPES * GENERIC_TYPES) + (type * RTD_TYPES) + RTD_COUNT]; + unsigned long long sum = M_rtdInfo[((which - 1) * RTD_TYPES * GENERIC_TYPES) + (type * RTD_TYPES) + RTD_SUM]; + unsigned long long sumsq = M_rtdInfo[((which - 1) * RTD_TYPES * GENERIC_TYPES) + (type * RTD_TYPES) + RTD_SUMSQ]; + + if (count <= 1) + return 0.0; + + double numerator = ((double)count * (double)sumsq) - (double)(sum * sum); + double denominator = (double)(count) * ((double)(count) - 1.0); + + return sqrt(numerator/denominator); +} + void CStat::updateAverageCounter(E_CounterName P_SumCounter, E_CounterName P_NbOfCallUsed, E_CounterName P_Squares, @@ -848,7 +881,7 @@ } - M_genericCounters = (unsigned long long *)realloc(M_genericCounters, sizeof(unsigned long long) * 3 * M_genericMap.size()); + M_genericCounters = (unsigned long long *)realloc(M_genericCounters, sizeof(unsigned long long) * GENERIC_TYPES * M_genericMap.size()); if (!M_genericCounters) { ERROR("Could not allocate generic counters!\n"); } @@ -859,6 +892,67 @@ return ret; } +int CStat::findRtd(const char *name, bool start) { + str_int_map::iterator it = M_rtdMap.find(str_int_map::key_type(name)); + if (it != M_rtdMap.end()) { + if (start) { + rtd_started[it->first] = true; + } else { + rtd_stopped[it->first] = true; + } + return it->second; + } + + int ret = M_rtdMap.size() + 1; + M_rtdMap[str_int_map::key_type(name)] = ret; + + M_revRtdMap[ret] = strdup(name); + + + M_rtdInfo = (unsigned long long *)realloc(M_rtdInfo, sizeof(unsigned long long) * RTD_TYPES * GENERIC_TYPES * M_rtdMap.size()); + if (!M_rtdInfo) { + ERROR("Could not allocate RTD info!\n"); + } + M_rtdInfo[((ret - 1) * RTD_TYPES * GENERIC_TYPES) + (GENERIC_C * RTD_TYPES) + RTD_COUNT] = 0; + M_rtdInfo[((ret - 1) * RTD_TYPES * GENERIC_TYPES) + (GENERIC_C * RTD_TYPES) + RTD_SUM] = 0; + M_rtdInfo[((ret - 1) * RTD_TYPES * GENERIC_TYPES) + (GENERIC_C * RTD_TYPES) + RTD_SUMSQ] = 0; + + M_rtdInfo[((ret - 1) * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PD * RTD_TYPES) + RTD_COUNT] = 0; + M_rtdInfo[((ret - 1) * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PD * RTD_TYPES) + RTD_SUM] = 0; + M_rtdInfo[((ret - 1) * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PD * RTD_TYPES) + RTD_SUMSQ] = 0; + + M_rtdInfo[((ret - 1) * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PL * RTD_TYPES) + RTD_COUNT] = 0; + M_rtdInfo[((ret - 1) * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PL * RTD_TYPES) + RTD_SUM] = 0; + M_rtdInfo[((ret - 1) * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PL * RTD_TYPES) + RTD_SUMSQ] = 0; + + M_ResponseTimeRepartition = (T_dynamicalRepartition **)realloc(M_ResponseTimeRepartition, sizeof(T_dynamicalRepartition *) * M_rtdMap.size()); + if (!M_ResponseTimeRepartition) { + ERROR("Could not allocate RTD info!\n"); + } + M_ResponseTimeRepartition[ret - 1] = NULL; + + if (start) { + rtd_started[name] = true; + } else { + rtd_stopped[name] = true; + } + return ret; +} + +int CStat::nRtds() { + return M_rtdMap.size(); +} + +/* If you start an RTD, then you should be interested in collecting statistics for it. */ +void CStat::validateRtds() { + for (str_int_map::iterator it = rtd_started.begin(); it != rtd_started.end(); it++) { + str_int_map::iterator stopit = rtd_stopped.find(it->first); + if (stopit == rtd_stopped.end() || !stopit->second) { + ERROR("You have started Response Time Duration %s, but have never stopped it!", it->first.c_str()); + } + } +} + int CStat::computeStat (E_Action P_action, unsigned long P_value, int which) @@ -891,19 +985,20 @@ case E_ADD_RESPONSE_TIME_DURATION : // Updating Cumulative Counter - updateAverageCounter((E_CounterName)(CPT_C_AverageResponseTime_Sum + which), - (E_CounterName)(CPT_C_NbOfCallUsedForAverageResponseTime + which), - (E_CounterName)(CPT_C_AverageResponseTime_Squares + which), P_value); - updateRepartition(M_ResponseTimeRepartition[which], - M_SizeOfResponseTimeRepartition, P_value); + M_rtdInfo[(which * RTD_TYPES * GENERIC_TYPES) + (GENERIC_C * RTD_TYPES) + RTD_COUNT]++; + M_rtdInfo[(which * RTD_TYPES * GENERIC_TYPES) + (GENERIC_C * RTD_TYPES) + RTD_SUM] += P_value; + M_rtdInfo[(which * RTD_TYPES * GENERIC_TYPES) + (GENERIC_C * RTD_TYPES) + RTD_SUMSQ] += (P_value * P_value); + updateRepartition(M_ResponseTimeRepartition[which], M_SizeOfResponseTimeRepartition, P_value); + // Updating Periodical Diplayed counter - updateAverageCounter((E_CounterName)(CPT_PD_AverageResponseTime_Sum + which), - (E_CounterName)(CPT_PD_NbOfCallUsedForAverageResponseTime + which), - (E_CounterName)(CPT_PD_AverageResponseTime_Squares + which), P_value); + M_rtdInfo[(which * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PD * RTD_TYPES) + RTD_COUNT]++; + M_rtdInfo[(which * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PD * RTD_TYPES) + RTD_SUM] += P_value; + M_rtdInfo[(which * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PD * RTD_TYPES) + RTD_SUMSQ] += (P_value * P_value); + // Updating Periodical Logging counter - updateAverageCounter((E_CounterName)(CPT_PL_AverageResponseTime_Sum + which), - (E_CounterName)(CPT_PL_NbOfCallUsedForAverageResponseTime + which), - (E_CounterName)(CPT_PL_AverageResponseTime_Squares + which), P_value); + M_rtdInfo[(which * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PL * RTD_TYPES) + RTD_COUNT]++; + M_rtdInfo[(which * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PL * RTD_TYPES) + RTD_SUM] += P_value; + M_rtdInfo[(which * RTD_TYPES * GENERIC_TYPES) + (GENERIC_PL * RTD_TYPES) + RTD_SUMSQ] += (P_value * P_value); break; default : @@ -958,9 +1053,7 @@ 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_ResponseTimeRepartition = NULL; M_CallLengthRepartition = NULL; M_SizeOfResponseTimeRepartition = 0; M_SizeOfCallLengthRepartition = 0; @@ -1130,33 +1223,26 @@ DISPLAY_CROSS_LINE (); - for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) { - char s[15]; + for (int i = 1; i <= nRtds(); i++) { + char s[80]; - if (!main_scenario->rtd_stopped[i]) { - continue; - } + /* Skip if we aren't stopped. */ + assert(rtd_stopped[M_revRtdMap[i]] == true); - sprintf(s, "Response Time %d", i + 1); + sprintf(s, "Response Time %s", M_revRtdMap[i]); DISPLAY_TXT_COL (s, - msToHHMMSSmmm( (unsigned long)computeMean((E_CounterName)(CPT_PD_AverageResponseTime_Sum + i), (E_CounterName)(CPT_PD_NbOfCallUsedForAverageResponseTime + i)) ), - msToHHMMSSmmm( (unsigned long)computeMean((E_CounterName)(CPT_C_AverageResponseTime_Sum + i), (E_CounterName)(CPT_C_NbOfCallUsedForAverageResponseTime + i)) ) ); + msToHHMMSSmmm( (unsigned long)computeRtdMean(i, GENERIC_PD)), + msToHHMMSSmmm( (unsigned long)computeRtdMean(i, GENERIC_C))); } - DISPLAY_TXT_COL ("Call Length", +/* I Broke this! + DISPLAY_TXT_COL ("Call Length", msToHHMMSSmmm( (unsigned long)computeMean(CPT_PD_AverageCallLength_Sum, CPT_PD_NbOfCallUsedForAverageCallLength)), msToHHMMSSmmm( (unsigned long)computeMean(CPT_C_AverageCallLength_Sum, CPT_C_NbOfCallUsedForAverageCallLength) )); +*/ DISPLAY_CROSS_LINE (); - for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) { - char s[50]; - - if (!main_scenario->rtd_stopped[i]) { - continue; - } - - sprintf(s, "Average Response Time Repartition, %d", i + 1); - DISPLAY_INFO(s); - displayRepartition(f, M_ResponseTimeRepartition[i], M_SizeOfResponseTimeRepartition); + for (int i = 1; i <= nRtds(); i++) { + displayRtdRepartition(f, i); } DISPLAY_INFO("Average Call Length Repartition"); displayRepartition(f, M_CallLengthRepartition, M_SizeOfCallLengthRepartition); @@ -1249,18 +1335,13 @@ // M_counters[CPT_C_UnexpectedMessage]); DISPLAY_CROSS_LINE (); - for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) { - char s[20]; + for (int i = 1; i <= nRtds(); i++) { + char s[80]; - if (!main_scenario->rtd_stopped[i]) { - continue; - } - - - sprintf(s, "Response Time %d", i + 1); + sprintf(s, "Response Time %s", M_revRtdMap[i]); DISPLAY_TXT_COL (s, - msToHHMMSSmmm( (unsigned long)computeMean((E_CounterName)(CPT_PD_AverageResponseTime_Sum + i), (E_CounterName)(CPT_PD_NbOfCallUsedForAverageResponseTime + i)) ), - msToHHMMSSmmm( (unsigned long)computeMean((E_CounterName)(CPT_C_AverageResponseTime_Sum + i), (E_CounterName)(CPT_C_NbOfCallUsedForAverageResponseTime + i)))); + msToHHMMSSmmm( (unsigned long)computeRtdMean(i, GENERIC_PD)), + msToHHMMSSmmm( (unsigned long)computeRtdMean(i, GENERIC_C))); } DISPLAY_TXT_COL ("Call Length", msToHHMMSSmmm( (unsigned long)computeMean(CPT_PD_AverageCallLength_Sum, CPT_PD_NbOfCallUsedForAverageCallLength ) ), @@ -1270,21 +1351,25 @@ void CStat::displayRepartition (FILE *f) { - DISPLAY_INFO("Average Response Time Repartition"); - displayRepartition(f, - M_ResponseTimeRepartition[0], - M_SizeOfResponseTimeRepartition); + displayRtdRepartition(f, 1); DISPLAY_INFO("Average Call Length Repartition"); displayRepartition(f, M_CallLengthRepartition, M_SizeOfCallLengthRepartition); } -void CStat::displaySecondaryRepartition (FILE *f, int which) +void CStat::displayRtdRepartition (FILE *f, int which) { - DISPLAY_INFO("Average Response Time Repartition"); + if (which > nRtds()) { + DISPLAY_INFO (" <No repartion defined>"); + return; + } + + char s[80]; + snprintf(s, sizeof(s), "Average Response Time Repartition %s", M_revRtdMap[which]); + DISPLAY_INFO(s); displayRepartition(f, - M_ResponseTimeRepartition[which], + M_ResponseTimeRepartition[which - 1], M_SizeOfResponseTimeRepartition); } @@ -1395,21 +1480,17 @@ << "WatchdogMinor(P)" << stat_delimiter << "WatchdogMinor(C)" << stat_delimiter; - for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) { - char s_P[30]; - char s_C[30]; + for (int i = 1; i <= nRtds(); i++) { + char s_P[80]; + char s_C[80]; - if (!main_scenario->rtd_stopped[i]) { - continue; - } + sprintf(s_P, "ResponseTime%s(P)%s", M_revRtdMap[i], stat_delimiter); + sprintf(s_C, "ResponseTime%s(C)%s", M_revRtdMap[i], stat_delimiter); - sprintf(s_P, "ResponseTime%d(P)%s", i + 1, stat_delimiter); - sprintf(s_C, "ResponseTime%d(C)%s", i + 1, stat_delimiter); - (*M_outputStream) << s_P << s_C; - sprintf(s_P, "ResponseTime%dStDev(P)%s", i + 1, stat_delimiter); - sprintf(s_C, "ResponseTime%dStDev(C)%s", i + 1, stat_delimiter); + sprintf(s_P, "ResponseTime%sStDev(P)%s", M_revRtdMap[i], stat_delimiter); + sprintf(s_C, "ResponseTime%sStDev(C)%s", M_revRtdMap[i], stat_delimiter); (*M_outputStream) << s_P << s_C; } @@ -1422,15 +1503,11 @@ (*M_outputStream) << M_revGenericMap[i] << "(P)" << stat_delimiter; (*M_outputStream) << M_revGenericMap[i] << "(C)" << stat_delimiter; } - for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) { - char s[30]; + for (int i = 1; i <= nRtds(); i++) { + char s[80]; - if (!main_scenario->rtd_stopped[i]) { - continue; - } - - sprintf(s, "ResponseTimeRepartition%d", i + 1); - (*M_outputStream) << sRepartitionHeader(M_ResponseTimeRepartition[i], + sprintf(s, "ResponseTimeRepartition%s", M_revRtdMap[i]); + (*M_outputStream) << sRepartitionHeader(M_ResponseTimeRepartition[i - 1], M_SizeOfResponseTimeRepartition, s); } @@ -1507,26 +1584,11 @@ << M_G_counters[CPT_G_C_WatchdogMinor - E_NB_COUNTER - 1] << stat_delimiter; // SF917289 << M_counters[CPT_C_UnexpectedMessage] << stat_delimiter; - for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) { - if (!main_scenario->rtd_stopped[i]) { - continue; - } - - (*M_outputStream) - << msToHHMMSSmmm( (unsigned long)computeMean((E_CounterName)(CPT_PL_AverageResponseTime_Sum + i), - (E_CounterName)(CPT_PL_NbOfCallUsedForAverageResponseTime + i))) << stat_delimiter; - (*M_outputStream) - << msToHHMMSSmmm( (unsigned long)computeMean((E_CounterName)(CPT_C_AverageResponseTime_Sum + i), - (E_CounterName)(CPT_C_NbOfCallUsedForAverageResponseTime + i))) << stat_delimiter; - - (*M_outputStream) - << msToHHMMSSmmm( (unsigned long)computeStdev((E_CounterName)(CPT_PL_AverageResponseTime_Sum + i), - (E_CounterName)(CPT_PL_NbOfCallUsedForAverageResponseTime + i), - (E_CounterName)(CPT_PL_AverageResponseTime_Squares + i)) ) << stat_delimiter; - (*M_outputStream) - << msToHHMMSSmmm( (unsigned long)computeStdev((E_CounterName)(CPT_C_AverageResponseTime_Sum + i), - (E_CounterName)(CPT_C_NbOfCallUsedForAverageResponseTime + i), - (E_CounterName)(CPT_C_AverageResponseTime_Squares + i)) ) << stat_delimiter; + for (int i = 1; i <= nRtds(); i++) { + (*M_outputStream) << msToHHMMSSmmm( (unsigned long)computeRtdMean(i, GENERIC_PL)) << stat_delimiter; + (*M_outputStream) << msToHHMMSSmmm( (unsigned long)computeRtdMean(i, GENERIC_C)) << stat_delimiter; + (*M_outputStream) << msToHHMMSSmmm( (unsigned long)computeRtdStdev(i, GENERIC_PL)) << stat_delimiter; + (*M_outputStream) << msToHHMMSSmmm( (unsigned long)computeRtdStdev(i, GENERIC_C)) << stat_delimiter; } (*M_outputStream) << msToHHMMSSmmm( (unsigned long)computeMean(CPT_PL_AverageCallLength_Sum, CPT_PL_NbOfCallUsedForAverageCallLength) ) << stat_delimiter; @@ -1546,10 +1608,7 @@ (*M_outputStream) << M_genericCounters[GENERIC_TYPES * i + GENERIC_C] << stat_delimiter; } - for (int i = 0; i < MAX_RTD_INFO_LENGTH; i++) { - if (!main_scenario->rtd_stopped[i]) { - continue; - } + for (int i = 0; i < nRtds(); i++) { (*M_outputStream) << sRepartitionInfo(M_ResponseTimeRepartition[i], M_SizeOfResponseTimeRepartition); Modified: sipp/trunk/stat.hpp =================================================================== --- sipp/trunk/stat.hpp 2008-07-14 19:23:46 UTC (rev 506) +++ sipp/trunk/stat.hpp 2008-07-14 20:11:51 UTC (rev 507) @@ -48,12 +48,6 @@ #include "variables.hpp" -/* MAX_RTD_INFO_LENGTH defines the number of RTD begin and end points a single - * call can have. If you need more than five, you can increase this number, - * but you also need to insert entries into the E_CounterName enum in stat.hpp. - */ -#define MAX_RTD_INFO_LENGTH 5 - using namespace std; /* @@ -142,21 +136,6 @@ CPT_C_NbOfCallUsedForAverageCallLength, CPT_C_AverageCallLength_Sum, CPT_C_AverageCallLength_Squares, - CPT_C_NbOfCallUsedForAverageResponseTime, - CPT_C_NbOfCallUsedForAverageResponseTime_2, - CPT_C_NbOfCallUsedForAverageResponseTime_3, - CPT_C_NbOfCallUsedForAverageResponseTime_4, - CPT_C_NbOfCallUsedForAverageResponseTime_5, // This must match or exceed MAX_RTD_INFO - CPT_C_AverageResponseTime_Sum, - CPT_C_AverageResponseTime_Sum_2, - CPT_C_AverageResponseTime_Sum_3, - CPT_C_AverageResponseTime_Sum_4, - CPT_C_AverageResponseTime_Sum_5, // This must match or exceed MAX_RTD_INFO - CPT_C_AverageResponseTime_Squares, - CPT_C_AverageResponseTime_Squares_2, - CPT_C_AverageResponseTime_Squares_3, - CPT_C_AverageResponseTime_Squares_4, - CPT_C_AverageResponseTime_Squares_5, CPT_C_FailedCallCannotSendMessage, CPT_C_FailedCallMaxUdpRetrans, CPT_C_FailedCallTcpConnect, @@ -379,9 +358,8 @@ void displayData (FILE *f); void displayStat(FILE *f); void displayRepartition(FILE *f); - void displaySecondaryRepartition (FILE *f, int which); + void displayRtdRepartition (FILE *f, int which); - /** * Dump data periodically in the file M_FileName */ @@ -432,6 +410,9 @@ /* Get a counter ID by name. */ int findCounter(const char *counter, bool alloc); + int findRtd(const char *name, bool start); + void validateRtds(); + int nRtds(); private: unsigned long long M_counters[E_NB_COUNTER]; @@ -447,7 +428,18 @@ int_str_map M_revGenericMap; int_str_map M_genericDisplay; - T_dynamicalRepartition* M_ResponseTimeRepartition[MAX_RTD_INFO_LENGTH]; + str_int_map rtd_started; + str_int_map rtd_stopped; + +#define RTD_COUNT 0 +#define RTD_SUM 1 +#define RTD_SUMSQ 2 +#define RTD_TYPES 3 + unsigned long long *M_rtdInfo; + str_int_map M_rtdMap; + int_str_map M_revRtdMap; + + T_dynamicalRepartition** M_ResponseTimeRepartition; T_dynamicalRepartition* M_CallLengthRepartition; int M_SizeOfResponseTimeRepartition; int M_SizeOfCallLengthRepartition; @@ -567,6 +559,10 @@ */ double computeMean(E_CounterName P_SumCounter, E_CounterName P_NbOfCallUsed); + + double computeRtdMean(int which, int type); + double computeRtdStdev(int which, int type); + /** * Effective C++ * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |