|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 4081 (0xff1)
Types: TextFile
Names: »saxer7.c«
└─⟦db229ac7e⟧ Bits:30007240 EUUGD20: SSBA 1.2 / AFW Benchmarks
└─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21E/saxer/saxer7.c«
#include <stdio.h>
#define CEIL(x) ((int) (x+1))
#include "../install/signal.h"
#include "saxer8.c"
/* DISK -- Develop timings of disk writes
**
** Use: saxerdisk [-w<record length>]
** [-m<max Mbytes to write>]
** [-t<max time for experiment (s)>]
** [-i<desired report interval (s) (goal)>]
**
** Will issue n-character writes to WFILE until disk full, announcing
** bytes-per-second thruput at intervals.
*/
#ifndef WFILE
#define WFILE "saxer.disk"
#endif
char wfile[20] = WFILE;
#ifndef NREPORT
#define NREPORT 1000 /* initial value for number of bytes to write between
reports; will be automatically adjusted */
#endif
long time(),t1, tot_nw = 0;
char chunk[4096];
int nw, fd;
int byebye();
long m = 10000000; /* max disk written in bytes */
int n = 512; /* length of write */
float interval; /* elapsed time in sec */
float I = 560.; /* desired reporting interval in sec */
float thruput; /* thruput in bytes per second */
float t = 600.; /* max time disk test */
main(argc,argv)
int argc; char **argv;
{
long nr, nrsav; /* nb bytes report interval */
int nrept = 0; /* number of reports thus far */
char *p; /* argv parameter pointer */
/*
** munch arglist.
*/
while (--argc>0 && (p = *++argv)[0]=='-')
switch (p[1])
{
case 'w': n = abs(atoi(p+=2)); break;/* bytes/write */
case 'm': m = 1000000*abs(atoi(p+=2)); break;/* max disk bytes */
case 't': alarm(2+(int) (t = 1.0*abs(atoi(p+=2)))); break; /* max timing */
case 'i': I = 1.0*abs(atoi(p+=2)); break; /* desired report interval in secs */
default: fprintf(stderr,"disk-unknown option %.10s\n",p),exit(1);
}
/*
** open file and unlink
*/
if ((fd = creat( wfile, 0777))<0 || unlink(wfile)<0)
exit(fprintf(stderr,"disk-cannot creat %s\n",wfile));
/*
** catch interrupt signals
*/
signal(SIGINT,byebye);
signal(SIGALRM,byebye);
/*
** write m-Mbyte file, record length n bytes, reporting
** statistics every i seconds.
*/
t1 = rtmsec();
nr = NREPORT; /* nbytes before report */
nrsav = NREPORT;
while ( tot_nw < m )
{
nw = write(fd,chunk,n);
if (nw>0)
tot_nw += nw; /* tally */
if (nw != n)
break; /* end of medium reached */
if((nr -= nw) < 0) /* if it's time to report (more than nr bytes written) */
{
/*
** report write disk statistics.
*/
interval = (rtmsec()-t1) / 1000. + .001; /* sec */
thruput = tot_nw / interval; /* bytes/sec */
if ( interval < .030 )
{nr += nr; continue;} /* if no time, double */
else
nr = ( (float) nrsav +I*thruput)/2.;
nrsav = nr;
if (interval>=t)
break; /* exit max time exceeded */
}
}
byebye();
}
byebye()
{
interval = (rtmsec()-t1) / 1000. + .001;
thruput = tot_nw/interval;
printf("\ndisk: %.3f Mb (%d bytes io) throughput %4.2f Kbytes/sec %5.1f seconds\n",
tot_nw/1000000.,nw,thruput/1000.,interval);
exit(0);
}