You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by cl...@apache.org on 2004/08/12 17:19:24 UTC

cvs commit: httpd-2.0/support ab.c

clar        2004/08/12 08:19:24

  Modified:    support  Tag: APACHE_2_0_BRANCH ab.c
  Log:
  bp of r1.143: fixed mean and median calculations, changed where time values for start and connect for ka
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.121.2.11 +40 -39    httpd-2.0/support/ab.c
  
  Index: ab.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/support/ab.c,v
  retrieving revision 1.121.2.10
  retrieving revision 1.121.2.11
  diff -u -r1.121.2.10 -r1.121.2.11
  --- ab.c	27 Mar 2004 00:08:41 -0000	1.121.2.10
  +++ ab.c	12 Aug 2004 15:19:23 -0000	1.121.2.11
  @@ -90,7 +90,7 @@
    * ab - or to due to a change in the distribution it is compiled with 
    * (such as an APR change in for example blocking).
    */
  -#define AP_AB_BASEREVISION "2.0.40-dev"    
  +#define AP_AB_BASEREVISION "2.0.41-dev"    
   
   /*
    * BUGS:
  @@ -864,10 +864,11 @@
   	/* work out connection times */
   	long i;
   	apr_time_t totalcon = 0, total = 0, totald = 0, totalwait = 0;
  +        apr_time_t meancon, meantot, meand, meanwait;
           apr_interval_time_t mincon = AB_MAX, mintot = AB_MAX, mind = AB_MAX, 
                               minwait = AB_MAX;
           apr_interval_time_t maxcon = 0, maxtot = 0, maxd = 0, maxwait = 0;
  -        apr_interval_time_t meancon = 0, meantot = 0, meand = 0, meanwait = 0;
  +        apr_interval_time_t mediancon = 0, mediantot = 0, mediand = 0, medianwait = 0;
           double sdtot = 0, sdcon = 0, sdd = 0, sdwait = 0;
   
   	for (i = 0; i < requests; i++) {
  @@ -887,21 +888,22 @@
   	    totald += s.time - s.ctime;
   	    totalwait += s.waittime;
   	}
  -	totalcon /= requests;
  -	total /= requests;
  -	totald /= requests;
  -	totalwait /= requests;
  +    meancon = totalcon / requests;
  +    meantot = total / requests;
  +    meand = totald / requests;
  +    meanwait = totalwait / requests;
   
  +    /* calculating the sample variance: the sum of the squared deviations, divided by n-1 */
   	for (i = 0; i < requests; i++) {
   	    struct data s = stats[i];
  -            double a;
  -            a = ((double)s.time - total);
  -            sdtot += a * a;
  -	    a = ((double)s.ctime - totalcon);
  +        double a;
  +        a = ((double)s.time - meantot);
  +        sdtot += a * a;
  +        a = ((double)s.ctime - meancon);
   	    sdcon += a * a;
  -	    a = ((double)s.time - (double)s.ctime - totald);
  +        a = ((double)s.time - (double)s.ctime - meand);
   	    sdd += a * a;
  -	    a = ((double)s.waittime - totalwait);
  +        a = ((double)s.waittime - meanwait);
   	    sdwait += a * a;
   	}
   
  @@ -943,31 +945,31 @@
   	qsort(stats, requests, sizeof(struct data),
   	      (int (*) (const void *, const void *)) compradre);
   	if ((requests > 1) && (requests % 2))
  -	    meancon = (stats[requests / 2].ctime + stats[requests / 2 + 1].ctime) / 2;
  +        mediancon = (stats[requests / 2].ctime + stats[requests / 2 + 1].ctime) / 2;
   	else
  -	    meancon = stats[requests / 2].ctime;
  +        mediancon = stats[requests / 2].ctime;
   
   	qsort(stats, requests, sizeof(struct data),
   	      (int (*) (const void *, const void *)) compri);
   	if ((requests > 1) && (requests % 2))
  -	    meand = (stats[requests / 2].time + stats[requests / 2 + 1].time \
  +        mediand = (stats[requests / 2].time + stats[requests / 2 + 1].time \
   	    -stats[requests / 2].ctime - stats[requests / 2 + 1].ctime) / 2;
   	else
  -	    meand = stats[requests / 2].time - stats[requests / 2].ctime;
  +        mediand = stats[requests / 2].time - stats[requests / 2].ctime;
   
   	qsort(stats, requests, sizeof(struct data),
   	      (int (*) (const void *, const void *)) compwait);
   	if ((requests > 1) && (requests % 2))
  -	    meanwait = (stats[requests / 2].waittime + stats[requests / 2 + 1].waittime) / 2;
  +        medianwait = (stats[requests / 2].waittime + stats[requests / 2 + 1].waittime) / 2;
   	else
  -	    meanwait = stats[requests / 2].waittime;
  +        medianwait = stats[requests / 2].waittime;
   
   	qsort(stats, requests, sizeof(struct data),
   	      (int (*) (const void *, const void *)) comprando);
   	if ((requests > 1) && (requests % 2))
  -	    meantot = (stats[requests / 2].time + stats[requests / 2 + 1].time) / 2;
  +        mediantot = (stats[requests / 2].time + stats[requests / 2 + 1].time) / 2;
   	else
  -	    meantot = stats[requests / 2].time;
  +        mediantot = stats[requests / 2].time;
   
   	printf("\nConnection Times (ms)\n");
   
  @@ -975,18 +977,18 @@
   #define CONF_FMT_STRING "%5" APR_TIME_T_FMT " %4d %5.1f %6" APR_TIME_T_FMT " %7" APR_TIME_T_FMT "\n"
   	    printf("              min  mean[+/-sd] median   max\n");
   	    printf("Connect:    " CONF_FMT_STRING, 
  -                   mincon, (int) (totalcon + 0.5), sdcon, meancon, maxcon);
  +                   mincon, (int) (meancon + 0.5), sdcon, mediancon, maxcon);
   	    printf("Processing: " CONF_FMT_STRING,
  -		   mind, (int) (totald + 0.5), sdd, meand, maxd);
  +		   mind, (int) (meand + 0.5), sdd, mediand, maxd);
   	    printf("Waiting:    " CONF_FMT_STRING,
  -	           minwait, (int) (totalwait + 0.5), sdwait, meanwait, maxwait);
  +	           minwait, (int) (meanwait + 0.5), sdwait, medianwait, maxwait);
   	    printf("Total:      " CONF_FMT_STRING,
  -		   mintot, (int) (total + 0.5), sdtot, meantot, maxtot);
  +		   mintot, (int) (meantot + 0.5), sdtot, mediantot, maxtot);
   #undef CONF_FMT_STRING
   
  -#define     SANE(what,avg,mean,sd) \
  +#define     SANE(what,mean,median,sd) \
                 { \
  -                double d = (double)avg - mean; \
  +                double d = (double)mean - median; \
                   if (d < 0) d = -d; \
                   if (d > 2 * sd ) \
                       printf("ERROR: The median and mean for " what " are more than twice the standard\n" \
  @@ -995,21 +997,20 @@
                       printf("WARNING: The median and mean for " what " are not within a normal deviation\n" \
                              "        These results are probably not that reliable.\n"); \
               }
  -	    SANE("the initial connection time", totalcon, meancon, sdcon);
  -	    SANE("the processing time", totald, meand, sdd);
  -	    SANE("the waiting time", totalwait, meanwait, sdwait);
  -	    SANE("the total time", total, meantot, sdtot);
  +        SANE("the initial connection time", meancon, mediancon, sdcon);
  +        SANE("the processing time", meand, mediand, sdd);
  +        SANE("the waiting time", meanwait, medianwait, sdwait);
  +        SANE("the total time", meantot, mediantot, sdtot);
   	}
   	else {
   	    printf("              min   avg   max\n");
   #define CONF_FMT_STRING "%5" APR_TIME_T_FMT " %5" APR_TIME_T_FMT "%5" APR_TIME_T_FMT "\n"
   	    printf("Connect:    " CONF_FMT_STRING, 
  -                   mincon, totalcon / requests, maxcon);
  -	    printf("Processing: " CONF_FMT_STRING, mintot - mincon, 
  -                   (total / requests) - (totalcon / requests), 
  -                   maxtot - maxcon);
  +                mincon, meancon, maxcon);
  +	    printf("Processing: " CONF_FMT_STRING, 
  +                mintot - mincon, meantot - meancon,  maxtot - maxcon);
   	    printf("Total:      " CONF_FMT_STRING, 
  -                   mintot, total / requests, maxtot);
  +                mintot, meantot, maxtot);
   #undef CONF_FMT_STRING
   	}
   
  @@ -1481,7 +1482,6 @@
       if (c->keepalive && (c->bread >= c->length)) {
   	/* finished a keep-alive connection */
   	good++;
  -	doneka++;
   	/* save out time */
   	if (good == 1) {
   	    /* first time here */
  @@ -1493,6 +1493,7 @@
   	}
   	if (done < requests) {
   	    struct data s;
  +	    doneka++;
   	    if (done && heartbeatres && !(done % heartbeatres)) {
   		fprintf(stderr, "Completed %ld requests\n", done);
   		fflush(stderr);
  @@ -1510,8 +1511,8 @@
   	c->gotheader = 0;
   	c->cbx = 0;
   	c->read = c->bread = 0;
  +	c->start = c->connect = apr_time_now();	/* zero connect time with keep-alive */
   	write_request(c);
  -	c->start = c->connect;	/* zero connect time with keep-alive */
       }
   }