Article View: gnu.gcc.help
Article #46661Slow disk access with djgpp 37kb/s with fwrite
From: A J Bryant
Date: Wed, 02 Nov 1994 15:50
Date: Wed, 02 Nov 1994 15:50
69 lines
2425 bytes
2425 bytes
I'm a little confused here. I have compiled the same source under djgpp, and
Zortech C++, and am seeing vastly different results. I am attempting to
write directly to the disk with the fwrite function. Under Gcc
1.12.maint2 I get a max rate of about 35.8 kb/s when saving a 2MB file.
With Zortech C++ v3, I get between 500 and 700 kb/s depending on the mode
my HDD controller is in.
What am I doing wrong? Thanks, Andy.
The source ....
#define NUM_KBYTES 2048
#define SIZE_OF_CHUNK 2048
#define CHUNKS (long unsigned int) NUM_KBYTES*1024/SIZE_OF_CHUNK
#include <stdio.h>
#include <time.h> /* clock() */
void main()
{
int i,index;
char data[SIZE_OF_CHUNK];
FILE *fptr;
int bool;
clock_t start,end;
double diff;
float rate;
printf("Populating array ...\n");
for (index=0; index <= SIZE_OF_CHUNK; index++) {
data[index] = index;
}
printf("\nOpening file ...\n");
fptr = fopen("test.dat", "w");
printf("Filling file ...\n");
if (fptr == NULL)+
printf("File could not be opened\n");
else {
start=clock();
/* Write CHUNKS*SIZE_OF_CHUNK bytes to file */
for ( i=CHUNKS ; i > 0 ; i-- ) {
/* Write SIZE_OF_CHUNK single bytes to file */
fwrite( &data, 1, SIZE_OF_CHUNK, fptr);
}
end=clock();
}
diff = (double) ( end - start ) / CLOCKS_PER_SEC;
printf("Chunk size %d b \n", SIZE_OF_CHUNK );
printf("Size of test %d kb \n", NUM_KBYTES );
if (diff != 0)
rate = NUM_KBYTES / diff;
else
rate = 0;
printf("Rate: %.1f kb/s \n", rate );
fclose(fptr);
}
Technical Details
Message-ID:
<398cfi$dqr@bosch.ecs.soton.ac.uk>Path:
arc1-ca.pugleaf.net!nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!udel!news.mathworks.com!news.duke.edu!news-feed-1.peachnet.edu!gatech!howland.reston.ans.net!pipex!lyra.csx.cam.ac.uk!sunsite.doc.ic.ac.uk!bright.ecs.soton.ac.uk!bosch.ecs.soton.ac.uk!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,fd039041cfbceceb,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1994-11-02 07:50:10 PST Path: arc1-ca.pugleaf.net!nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!udel!news.mathworks.com!news.duke.edu!news-feed-1.peachnet.edu!gatech!howland.reston.ans.net!pipex!lyra.csx.cam.ac.uk!sunsite.doc.ic.ac.uk!bright.ecs.soton.ac.uk!bosch.ecs.soton.ac.uk!not-for-mail From: ajb92@ecs.soton.ac.uk (A J Bryant) Newsgroups: gnu.gcc.help Subject: Slow disk access with djgpp 37kb/s with fwrite Date: 2 Nov 1994 15:50:10 -0000 Organization: Electronics and Computer Science, University of Southampton Lines: 70 Message-ID: <398cfi$dqr@bosch.ecs.soton.ac.uk> NNTP-Posting-Host: bosch.ecs.soton.ac.uk