ARP 1.1 (Disk 85) (Mar 1988) : DriveTest / autotest.c

/*M*	autotest.c - test raw disk I/O */

/*
 *	Original program from PC Tech Journal, November 1984
 *	"Fixed-disk Benchmark" by William Hunt
 *
 *	Ported to the AMIGA by Michael L. Hitch, 1986
*/

#include <stdio.h>

#define	ASIZE	25000
#define	CLCKRES	50		/* clock resolution; tics/second */

int dno, nstart, i, nit;
char *pbuf;
int clu, frees, tot, bps;
int totsec;
char area[ASIZE];

main(argc, argv)
int argc;
char *argv[];
{
	pbuf = argv[1];
	if (argc < 2)
	{
		printf("Drive name: ");
		fgets(area, 80, stdin);
		pbuf = area;
		while (*pbuf && *pbuf != '\n')
			++pbuf;
		*pbuf = 0;
		pbuf = area;
	}
	printf ("Autotest:  device name %s\n", pbuf);
	clu = getspace(pbuf, &frees, &tot, &bps);
	pbuf = area;
	printf("%d sectors/cluster, %d free, %d total, %d bytes/sector\n",
        	clu, frees, tot, bps);
	if (clu < 0)
	{
		printf("%s is an invalid drive name\n", area);
		exit(0);
	}
	totsec = clu * tot;
	printf("Total number of sectors = %d\n", totsec);
	nstart = 0; nit = 20;
	printf("Sequential reads\n");
	doseq(1);
	doseq(8);
	doseq(16);
	doseq(24);
	nit = 40;
	printf("Random reads - %d sector\n", 1);
	dorand(1, 10);
	dorand(1, 33);
	dorand(1, 50);
	dorand(1, 90);
	printf("Random reads - %d sector\n", 8);
	nit = 20;
	dorand(8, 10);
	dorand(8, 33);
	dorand(8, 50);
	dorand(8, 90);
	cleanup();
}

doseq(nseg)
int nseg;
{
	int t;

	t = seqio(dno, nseg, nstart, pbuf, nit);
	printf("%2d sectors          - ", nseg);
	t = t * 1000;			/* scale to .001 seconds */
	printf("%d.%03d Sec/read\n", 
		t / (1000 * CLCKRES * nit), t / (CLCKRES * nit) % 1000);
}

dorand(nseg, frac)
int nseg, frac;
{
	int t;
	int offset;

	offset = totsec * frac / 100;
	t = randio(dno, nseg, nstart, pbuf, nit, offset);
	printf(".%02d width seeks   - ", frac); 
	t = t * 1000;
	printf("%d.%03d Sec/read\n",
		t / (1000 * CLCKRES * nit), t / (CLCKRES * nit) % 1000);
}