[COMP] Disk Drive Test Program
- From: "Michael V. Franklin" <Slavo@xxxxxxxxxxxx>
- To: "Avenir Mailing List (E-mail)" <computers@xxxxxxxxxxxxxx>
- Date: Fri, 25 Feb 2000 21:26:45 -0800
Since we've been having a disk performance discussion, I wrote this program
for Linux users who want to test their drives.
Just compile it and type "./a.out /dev/hda1 100"
For those who don't know how to do this, just copy the test to a text file
called disktest.c and at the prompt type "cc disktest.c". Then type the
command above (no quotes).
This will test your first hard drive partition with a read of 100MB. It
should work for any drive and any number of MB below 4GB. It only reads
from one sector on the disk so I think you can type any number of MB even
for a floppy (No guarantees though).
It should work pretty well, but USE IT AT YOUR OWN RISK. I just thought you
guys might want something like this. If someone would like a Windows
version, let me know and I'll put one together real quick.
#include <time.h>
#include <fcntl.h>
#include <stdlib.h>
#define BLKSIZE 1024
int main(int argc, char *argv[])
{
char buffer[BLKSIZE];
int fileDescrip;
long count;
int nMBtoRead;
long nBytesRead;
clock_t start, end;
float totalTime;
nMBtoRead = atoi(argv[2]);
fileDescrip = open(argv[1], O_RDONLY);
if (fileDescrip < 0) {
printf("Error: Cannont open %s\n", argv[1]);
exit(0);
}
nBytesRead = 0;
start = time(NULL);
for(count=0; count<(nMBtoRead * 1024); count++)
{
nBytesRead = nBytesRead + read (fileDescrip, buffer, BLKSIZE);
}
end = time(NULL);
totalTime = (float)(end - start);
printf("\n----------Results-----------\n");
printf("Read %ld MB\n", nBytesRead/1024/1024);
printf("Process took %0.3f seconds\n", totalTime);
printf("-----------------------------\n");
printf("\nYour drive reads at %0.3fMB/sec\n\n",
(float)(nBytesRead/1024/1024/totalTime));
close(fileDescrip);
return 0;
}
========================================
Avenir Web's Computers Mailing List
List Modes, Subscription, and General Info:
Go to http://avenir.dhs.org/mailing.html
List Archives: http://avenir.dhs.org/archives/
Administrative Contact: weez@xxxxxxxxxxxxxx
Get computer help: http://avenir.dhs.org
========================================
- Follow-Ups:
- Re: [COMP] Disk Drive Test Program
- From: John Madden
Other related posts:
- » [COMP] Disk Drive Test Program
- Re: [COMP] Disk Drive Test Program
- From: John Madden