summaryrefslogtreecommitdiff
path: root/apps/JAWS/clients/WebSTONE/src/bench.c
blob: 48007321f236d91c1ecb3ea522c2e74b9762363c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
/**************************************************************************
 *									  *
 * 		 Copyright (C) 1995 Silicon Graphics, Inc.		  *
 *									  *
 *  These coded instructions, statements, and computer programs were	  *
 *  developed by SGI for public use.  If any changes are made to this code*
 *  please try to get the changes back to the author.  Feel free to make  *
 *  modifications and changes to the code and release it.		  *
 *									  *
 **************************************************************************/

#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <math.h>
#include <limits.h>
#include <float.h>
#ifndef WIN32
#include <unistd.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/param.h>
#include <netdb.h>
#else
#include <windows.h>
#include <winsock.h>
#endif /* WIN32 */
#include "sysdep.h"
#include "bench.h"


/* allocate memory and exit if out of memory */
void *mymalloc(size_t size) {
void *ptr;

    ptr = malloc(size);
    if (ptr == NULL)
	errexit("Call to malloc() failed\n");
    return ptr;
}

/* 
 * Receive n bytes from a socket
 */
int
recvdata(SOCKET sock, char *ptr, int nbytes) {

  int nleft, nread;

  nleft = nbytes;
  while (nleft > 0) 
    {
      D_PRINTF( "In recvdata(%d, %d)\n", sock, nleft );
      nread = NETREAD(sock, ptr, nleft);
      D_PRINTF( "NETREAD() returned %d\n", nread );
      if (BADSOCKET(nread) || nread == 0)
	{
	  /* return error value NETWRITE */
          D_PRINTF( "Error in recvdata(): %s\n",neterrstr() );
	  return(nread);
	}
					     
      D_PRINTF( "NETREAD() data: \"%.*s\"\n", nread, ptr);
      nleft -= nread;
      ptr   += nread;
    } /* end while */

  /* return >= 0 */
  return(nbytes - nleft);

} /* end recvdata */


/*
 * Send n bytes to a socket
 */
int
senddata(SOCKET sock, char *ptr, int nbytes) {
  int nleft, nwritten;

  D_PRINTF( "In senddata(%d, \"%.*s\", %d)\n", sock, nbytes, ptr, nbytes );
  nleft = nbytes;
  while (nleft > 0)
    {
      nwritten = NETWRITE(sock, ptr, nleft);
      D_PRINTF( "senddata() returned %d\n", nwritten );
      if (BADSOCKET(nwritten))
	{
	  /* return error value from NETWRITE */
          D_PRINTF( "Error in senddata(): %s\n", neterrstr() );
	  return(nwritten);
	}
      nleft -= nwritten;
      ptr += nwritten;
    }
  return(nbytes - nleft);

} /* end senddata */

/* GENERAL NOTE: the conversion routines that follow pass their results
 * back in a static arrays.  A second call to the same routine overwrites
 * the previous buffer value for that routine.  If you want to save the
 * value in the buffer copy it to another variable.
 */

char *
timeval_to_text(const struct timeval *the_timeval) {
  /* 
   * given a timeval (seconds and microseconds), put the text
   * "seconds.microseconds" into timeval_as_text
   */
  THREAD static char timeval_as_text[SIZEOF_TIMEVALTEXT+1];
  int seconds, microseconds;
  int returnval = 0;

  seconds = the_timeval->tv_sec;
  microseconds = the_timeval->tv_usec;
  returnval = sprintf(timeval_as_text, 
		      "%10d.%6.6d\t", seconds, microseconds);
  return timeval_as_text;
}


char *
double_to_text(const double the_double) {
  /*
   * given a double, return text
   */
  THREAD static char double_as_text[SIZEOF_DOUBLETEXT + 1];
  int returnval = 0;

  returnval = sprintf(double_as_text, "%17.01f\t", the_double);
  return(double_as_text);
}

struct timeval
text_to_timeval(char *timeval_as_text) { 
  int returnval = 0;
  long int seconds, microseconds;
  struct timeval the_timeval;

  D_PRINTF("T/%d %s\n", (int)timeval_as_text, timeval_as_text);
  returnval = sscanf(timeval_as_text, "%ld.%ld", 
		     &seconds, &microseconds);
  the_timeval.tv_sec = seconds;
  the_timeval.tv_usec = microseconds;
  return the_timeval;
}

double
text_to_double(char *double_as_text) {
  double the_double = 0;
  int returnval = 0;

  D_PRINTF("D/%d %s\n", (int)double_as_text, double_as_text);
  returnval = sscanf(double_as_text, "%lf", &the_double);
  return(the_double);
}   


rqst_stats_t *
text_to_rqst_stats(char *rqst_stats_as_text) {
  THREAD static rqst_stats_t rqst_stats;
  rqst_stats_t *the_rqst_stats = &rqst_stats;

  the_rqst_stats->totalresponsetime = 
    text_to_timeval(strtok(rqst_stats_as_text, "\t"));
 
  the_rqst_stats->totalresponsetimesq = 
    text_to_double(strtok((char *)NULL, "\t")); 
			     			       
  the_rqst_stats->minresponsetime = 
    text_to_timeval(strtok((char *)NULL, "\t"));
			     
  the_rqst_stats->maxresponsetime = 
    text_to_timeval(strtok((char *)NULL, "\t"));
			     
  the_rqst_stats->totalconnecttime = 
    text_to_timeval(strtok((char *)NULL, "\t"));
			      
  the_rqst_stats->totalconnecttimesq = 
    text_to_double(strtok((char *)NULL, "\t"));
			       
  the_rqst_stats->minconnecttime = 
    text_to_timeval(strtok((char *)NULL, "\t"));
			     
  the_rqst_stats->maxconnecttime = 
    text_to_timeval(strtok((char *)NULL, "\t"));
			      
  the_rqst_stats->totalconnects = (unsigned long)
    text_to_double(strtok((char *)NULL, "\t"));
			       
  the_rqst_stats->totalerrs = (unsigned long)
    text_to_double(strtok((char *)NULL, "\t"));
			         
  the_rqst_stats->totalerrortime = 
    text_to_timeval(strtok((char *)NULL, "\t"));
			       
  the_rqst_stats->totalbytes = 
    text_to_double(strtok((char *)NULL, "\t"));
			        
  the_rqst_stats->totalbytessq = 
    text_to_double(strtok((char *)NULL, "\t"));
			         
  the_rqst_stats->minbytes = 
    text_to_double(strtok((char *)NULL, "\t"));
			         
  the_rqst_stats->maxbytes = 
    text_to_double(strtok((char *)NULL, "\t"));
			         
  the_rqst_stats->totalbody = 
    text_to_double(strtok((char *)NULL, "\t"));
			         
  the_rqst_stats->totalbodysq = 
    text_to_double(strtok((char *)NULL, "\t"));
			         
  the_rqst_stats->minbody = 
    text_to_double(strtok((char *)NULL, "\t"));
			        
  the_rqst_stats->maxbody = 
    text_to_double(strtok((char *)NULL, "\t"));

  return(the_rqst_stats);
} /* end text_to_rqst_stats */


char *
rqst_stats_to_text(rqst_stats_t *the_rqst_stats) {
  THREAD static char rqst_stats_as_text[SIZEOF_RQSTSTATSTEXT];
  char *tmpbuf;

  *rqst_stats_as_text = 0;

  tmpbuf = timeval_to_text(&(the_rqst_stats->totalresponsetime));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->totalresponsetimesq));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = timeval_to_text(&(the_rqst_stats->minresponsetime));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = timeval_to_text(&(the_rqst_stats->maxresponsetime));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = timeval_to_text(&(the_rqst_stats->totalconnecttime));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->totalconnecttimesq));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = timeval_to_text(&(the_rqst_stats->minconnecttime));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = timeval_to_text(&(the_rqst_stats->maxconnecttime));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->totalconnects));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->totalerrs));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = timeval_to_text(&(the_rqst_stats->totalerrortime));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->totalbytes));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->totalbytessq));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->minbytes));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->maxbytes));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->totalbody));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->totalbodysq));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->minbody));
  strcat(rqst_stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_rqst_stats->maxbody));
  strcat(rqst_stats_as_text, tmpbuf);

  D_PRINTF( "rqst_stats_to_text returning %d: %s\n", 
    strlen(rqst_stats_as_text),
    rqst_stats_as_text );

  return(rqst_stats_as_text);
}


stats_t * 
text_to_stats(char *stats_as_text) {
  int i;
  rqst_stats_t *the_rqst_stats;
  THREAD static stats_t stats;
  stats_t *the_stats = &stats;

  D_PRINTF( "Parsing stats: %s\n", stats_as_text );
  /* grab stats.rs */
  the_rqst_stats = text_to_rqst_stats(stats_as_text);
  the_stats->rs = *the_rqst_stats;

  /* grab main structure */
  the_stats->starttime = text_to_timeval(strtok((char *)NULL, "\t"));  
  the_stats->endtime = text_to_timeval(strtok((char *)NULL, "\t"));  
  the_stats->datatime = text_to_timeval(strtok((char *)NULL, "\t"));  
  the_stats->totalpages = (unsigned long) text_to_double(strtok((char *)NULL, "\t"));  
  the_stats->total_num_of_files = (unsigned int) text_to_double(strtok((char *)NULL, "\t"));  
  for (i = 0; i < number_of_pages; i++) 
    {   
      the_stats->page_numbers[i] = (unsigned int) text_to_double(strtok((char *)NULL, "\t"));
    }
  /* return bytes read */
  D_PRINTF( "Returning stats\n");
  return(the_stats);
} /* end text_to_stats */



char * 
stats_to_text(const stats_t *the_stats) {
  int    i;
  THREAD static char  stats_as_text[SIZEOF_STATSTEXT];
  char  *tmpbuf;
  rqst_stats_t the_rqst_stats;

  *stats_as_text = 0;

  /* stats.rs */
  the_rqst_stats = the_stats->rs;
  tmpbuf = rqst_stats_to_text(&the_rqst_stats);
  strcat(stats_as_text, tmpbuf);

  /* main structure */

  tmpbuf = timeval_to_text(&(the_stats->starttime));  
  strcat(stats_as_text, tmpbuf);

  tmpbuf = timeval_to_text(&(the_stats->endtime));  
  strcat(stats_as_text, tmpbuf);
  
  tmpbuf = timeval_to_text(&(the_stats->datatime));  
  strcat(stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_stats->totalpages));  
  strcat(stats_as_text, tmpbuf);

  tmpbuf = double_to_text((the_stats->total_num_of_files));  
  strcat(stats_as_text, tmpbuf);

  for (i = 0; i < number_of_pages; i++) 
    {   
      tmpbuf = double_to_text((the_stats->page_numbers[i]));      
      strcat(stats_as_text, tmpbuf);
    }

  strcat(stats_as_text, "\n");

  return(stats_as_text);
} /* end stats_to_text */



page_stats_t *
text_to_page_stats(char *page_stats_as_text) {
  rqst_stats_t *the_rqst_stats;
  THREAD static page_stats_t pagestat;
  page_stats_t *pagestats = &pagestat;

  /* grab stats.rs */
  the_rqst_stats = text_to_rqst_stats(page_stats_as_text);

  /* grab main structure */
  pagestats->totalpages = (unsigned long) text_to_double(strtok((char *)NULL, "\t")); 
			     
  pagestats->page_size = (unsigned int) text_to_double(strtok((char *)NULL, "\t")); 
			     
  pagestats->page_valid = (int) text_to_double(strtok((char *)NULL, "\t")); 
			    
  pagestats->rs = *the_rqst_stats;
  /* return bytes read */

  return(pagestats);
} /* end text_to_page_stats */



char * 
page_stats_to_text(const page_stats_t *pagestats) {
  THREAD static char page_stats_as_text[SIZEOF_PAGESTATSTEXT];
  char  *tmpbuf;
  rqst_stats_t the_rqst_stats;

  *page_stats_as_text = 0;

  /* stats.rs */
  the_rqst_stats = pagestats->rs;
  tmpbuf = rqst_stats_to_text(&the_rqst_stats);
  strcat(page_stats_as_text, tmpbuf);

  /* main structure */
  tmpbuf = double_to_text(pagestats->totalpages);  
  strcat(page_stats_as_text, tmpbuf);

  tmpbuf = double_to_text(pagestats->page_size);  
  strcat(page_stats_as_text, tmpbuf);

  tmpbuf = double_to_text(pagestats->page_valid);   
  strcat(page_stats_as_text, tmpbuf);

  strcat(page_stats_as_text, "\n");

  return(page_stats_as_text);
} /* end page_stats_to_text */

void
rqtimer_init(rqst_timer_t *p) {
    memset(p, 0, sizeof(*p));
}

void
rqstat_init(rqst_stats_t *p) {
    memset(p, 0, sizeof(*p));

    p->minbytes = DBL_MAX;
    p->minbody  = DBL_MAX;
    p->minconnecttime.tv_sec = LONG_MAX;
    p->minconnecttime.tv_usec = LONG_MAX;
    p->minresponsetime.tv_sec = LONG_MAX;
    p->minresponsetime.tv_usec = LONG_MAX;
}

void
stats_init(stats_t *p) {

    memset(p, 0, sizeof(*p));

    p->rs.minbytes = DBL_MAX;
    p->rs.minbody  = DBL_MAX;
    p->rs.minconnecttime.tv_sec = LONG_MAX;
    p->rs.minconnecttime.tv_usec = LONG_MAX;
    p->rs.minresponsetime.tv_sec = LONG_MAX;
    p->rs.minresponsetime.tv_usec = LONG_MAX;
}

void
page_stats_init(page_stats_t *p) {

    memset(p, 0, sizeof(*p));

    /* commented out so that unread pages result in
       page_stats_as_text buffer overflow
    p->rs.minbytes = DBL_MAX;
    p->rs.minbody  = DBL_MAX;
    p->rs.minconnecttime.tv_sec = LONG_MAX;
    p->rs.minconnecttime.tv_usec = LONG_MAX;
    p->rs.minresponsetime.tv_sec = LONG_MAX;
    p->rs.minresponsetime.tv_usec = LONG_MAX;

    */
}

void
rqstat_times(rqst_stats_t *rs, rqst_timer_t *rt)
{
    double    t;

    compdifftime(&(rt->exittime), &(rt->entertime),
						 &(rs->totalresponsetime));
    t = timevaldouble(&(rs->totalresponsetime));
    rs->totalresponsetimesq = t * t;

    rs->minresponsetime = rs->totalresponsetime;
    rs->maxresponsetime = rs->totalresponsetime;

    compdifftime(&(rt->afterconnect), &(rt->beforeconnect),
						 &(rs->totalconnecttime));

    t = timevaldouble(&(rs->totalconnecttime));
    rs->totalconnecttimesq = t * t;

    rs->minconnecttime = rs->totalconnecttime;
    rs->maxconnecttime = rs->totalconnecttime;

    rs->totalbody =   rt->bodybytes;
    rs->totalbodysq = ((double)(rt->bodybytes)) * ((double)(rt->bodybytes));
    rs->minbody =     rt->bodybytes;
    rs->maxbody =     rt->bodybytes;

    rs->totalbytes =   rt->totalbytes;
    rs->totalbytessq = ((double)(rt->totalbytes)) * ((double)(rt->totalbytes));
    rs->minbytes =     rt->totalbytes;
    rs->maxbytes =     rt->totalbytes;

    rs->totalconnects = 1;
    rs->totalerrs = 0;
    rs->totalerrortime.tv_sec = 0;
    rs->totalerrortime.tv_usec = 0;
}

void
rqstat_sum(rqst_stats_t *sum, rqst_stats_t *incr)
{
    addtime( &(sum->totalresponsetime),   &(incr->totalresponsetime));
    mintime( &(sum->minresponsetime),     &(incr->minresponsetime));
    maxtime( &(sum->maxresponsetime),     &(incr->maxresponsetime));
    sum->totalresponsetimesq += incr->totalresponsetimesq;

    addtime( &(sum->totalconnecttime),    &(incr->totalconnecttime));
    mintime( &(sum->minconnecttime),      &(incr->minconnecttime));
    maxtime( &(sum->maxconnecttime),      &(incr->maxconnecttime));
    sum->totalconnecttimesq += incr->totalconnecttimesq;

    sum->totalconnects += incr->totalconnects;
    sum->totalerrs     += incr->totalerrs;
    addtime( &(sum->totalerrortime), &(incr->totalerrortime));

    sum->totalbytes    += incr->totalbytes;

    sum->totalbytessq  += incr->totalbytessq;
    sum->minbytes      =  min(sum->minbytes, incr->minbytes);
    sum->maxbytes      =  max(sum->maxbytes, incr->maxbytes);

    sum->totalbody     += incr->totalbody;

    sum->totalbodysq   += incr->totalbodysq;
    sum->minbody       =  min(sum->minbody, incr->minbody);
    sum->maxbody       =  max(sum->maxbody, incr->maxbody);

}


void
rqstat_print(rqst_stats_t *stats)
{
    rqstat_fprint(stdout, stats);
}


void
rqstat_fprint(FILE *f, rqst_stats_t *stats)
{
    struct timeval meantime, /*vartime,*/ stdtime;

    fprintf(f, "%d connection(s) to server, %d errors\n",
	    stats->totalconnects, stats->totalerrs);

    if (stats->totalconnects == 0) {
	fprintf(f,"NO CONNECTIONS, THEREFORE NO STATISTICS\n"
		  "IS YOUR WEBSERVER RUNNING?\n"
		  "DO THE PAGES EXIST ON THE SERVER?\n");
	return;
    }

    /* title */
    fprintf(f, "\n\t\t\t   Average      Std Dev      Minimum      Maximum\n\n");

    /* first line (connect time) */
    avgtime(&(stats->totalconnecttime), 
				stats->totalconnects, &meantime);

    /* variancetime(&(stats->totalconnecttime),
				stats->totalconnecttimesq,
				stats->totalconnects, &vartime); */

    stddevtime(&(stats->totalconnecttime),
				stats->totalconnecttimesq,
				stats->totalconnects, &stdtime);

    fprintf(f, "Connect time (sec) \t%3d.%6.6d   %3d.%6.6d   %3d.%6.6d   %3d.%6.6d\n",
				meantime.tv_sec,
				meantime.tv_usec,
				stdtime.tv_sec,
				stdtime.tv_usec,
				stats->minconnecttime.tv_sec,
				stats->minconnecttime.tv_usec,
				stats->maxconnecttime.tv_sec,
				stats->maxconnecttime.tv_usec);

    /* second line (response time) */
    avgtime(&(stats->totalresponsetime), 
				stats->totalconnects, &meantime);

    /* variancetime(&(stats->totalresponsetime),
				stats->totalresponsetimesq,
				stats->totalconnects, &vartime); */

    stddevtime(&(stats->totalresponsetime),
				stats->totalresponsetimesq,
				stats->totalconnects, &stdtime);

    fprintf(f, "Response time (sec) \t%3d.%6.6d   %3d.%6.6d   %3d.%6.6d   %3d.%6.6d\n",
				meantime.tv_sec,
				meantime.tv_usec,
				stdtime.tv_sec,
				stdtime.tv_usec,
				stats->minresponsetime.tv_sec,
				stats->minresponsetime.tv_usec,
				stats->maxresponsetime.tv_sec,
				stats->maxresponsetime.tv_usec);

    /* 3rd-5th lines (response size, body size, # bytes moved */
    fprintf(f, "Response size (bytes) \t%10.0lf   %10.0lf   %10.0lf   %10.0lf\n",
	    mean(stats->totalbytes, stats->totalconnects),
	    stddev(stats->totalbytes, stats->totalbytessq,
			stats->totalconnects),
	    stats->minbytes,
	    stats->maxbytes);

    fprintf(f, "Body size (bytes) \t%10.0lf   %10.0lf   %10.0lf   %10.0lf\n\n",
	    mean(stats->totalbody, stats->totalconnects),
	    stddev(stats->totalbody, stats->totalbodysq,
			stats->totalconnects),
	    stats->minbody,
	    stats->maxbody);

    fprintf(f, "%.0lf body bytes moved + %.0lf header bytes moved = %.0lf total\n",
	    stats->totalbody,
	    stats->totalbytes - stats->totalbody,
	    stats->totalbytes);

}